React-native: after upgrade to 0.56.0-rc.2 production build is crashing

Created on 20 Jun 2018  ·  93Comments  ·  Source: facebook/react-native

Environment

React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
      Memory: 881.80 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 9.11.1 - ~/.nvm/versions/node/v9.11.1/bin/node
      Yarn: 1.7.0 - ~/.yarn/bin/yarn
      npm: 5.6.0 - ~/.nvm/versions/node/v9.11.1/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
      Android SDK:
        Build Tools: 23.0.1, 25.0.2, 25.0.3, 26.0.1, 27.0.1, 27.0.3
        API Levels: 23, 24, 25, 26, 27
    IDEs:
      Android Studio: 3.1 AI-173.4720617
      Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.3.2 => 16.3.2 
      react-native: 0.56.0-rc.2 => 0.56.0-rc.2 

Description

the project normally functioning on 0.55.4 after react-native-git-upgrade 0.56.0-rc.2working in simulator, but crashing on start on real device with production build. I removed everything, but none is helping, app name is CasualPM, here is crash report:


Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0

Application Specific Information:
abort() called

Filtered syslog:
None found

Last Exception Backtrace:
0 CoreFoundation 0x1e4baf960 __exceptionPreprocess + 152
1 libobjc.A.dylib 0x1e3e6052c objc_exception_throw + 55
2 CasualPM 0x104926e88 _hidden#1135_ + 192136 (__hidden#2451_:132)
3 CasualPM 0x104912d28 _hidden#1136_ + 109864 (__hidden#1437_:854)
4 libdispatch.dylib 0x1e459a8a8 _dispatch_call_block_and_release + 23
5 libdispatch.dylib 0x1e459a85c _dispatch_client_callout + 15
6 libdispatch.dylib 0x1e45a8c28 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1063
7 CoreFoundation 0x1e4b61748 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 11
8 CoreFoundation 0x1e4b5f3e0 __CFRunLoopRun + 1975
9 CoreFoundation 0x1e4a98430 CFRunLoopRunSpecific + 435
10 Foundation 0x1e5519e84 -[NSRunLoop+ 32388 (NSRunLoop) runMode:beforeDate:] + 299
11 Foundation 0x1e5519cf4 -[NSRunLoop+ 31988 (NSRunLoop) runUntilDate:] + 87
12 CasualPM 0x104a203f4 _hidden#14662_ + 1213428 (__hidden#14672_:30)
13 CasualPM 0x1048fc9a8 _hidden#2_ + 18856 (__hidden#18_:51)
14 UIKitCore 0x2108cc350 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 407
15 UIKitCore 0x2108cda8c -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3339
16 UIKitCore 0x2108d33c8 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1775
17 UIKitCore 0x2110f200c __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 783
18 UIKitCore 0x2110eec9c +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 159
19 UIKitCore 0x2110f1c88 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 239
20 UIKitCore 0x2110f24c8 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 723
21 UIKitCore 0x2110b3084 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 295
22 UIKitCore 0x2110b2f0c -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 431
23 UIKitCore 0x2110f3f8c __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 219
24 UIKitCore 0x2110f4a7c _performActionsWithDelayForTransitionContext + 111
25 UIKitCore 0x2110f3e44 -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 247
26 UIKitCore 0x2110ee348 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 367
27 UIKitCore 0x2108d1854 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 539
28 UIKitCore 0x210903704 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 363
29 FrontBoardServices 0x1e75fafa0 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 443
30 FrontBoardServices 0x1e7605d6c __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 259
31 FrontBoardServices 0x1e7605460 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 63
32 libdispatch.dylib 0x1e459a85c _dispatch_client_callout + 15
33 libdispatch.dylib 0x1e459fe90 _dispatch_block_invoke_direct$VARIANT$mp + 223
34 FrontBoardServices 0x1e7639a14 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 39
35 FrontBoardServices 0x1e76396a0 -[FBSSerialQueue _performNext] + 415
36 FrontBoardServices 0x1e7639cbc -[FBSSerialQueue _performNextFromRunLoopSource] + 55
37 CoreFoundation 0x1e4b61b4c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 23
38 CoreFoundation 0x1e4b61acc __CFRunLoopDoSource0 + 87
39 CoreFoundation 0x1e4b613a4 __CFRunLoopDoSources0 + 175
40 CoreFoundation 0x1e4b5f044 __CFRunLoopRun + 1051
41 CoreFoundation 0x1e4a98430 CFRunLoopRunSpecific + 435
42 GraphicsServices 0x1e6dc7548 GSEventRunModal + 99
43 UIKitCore 0x2108d51e0 UIApplicationMain + 211
44 CasualPM 0x1048fca68 main + 19048 (__hidden#21_:14)
45 libdyld.dylib 0x1e460cfa8 start + 3

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001e475867c __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001e47d7520 pthread_kill$VARIANT$mp + 384
2 libsystem_c.dylib 0x00000001e46bab80 abort + 140
3 libc++abi.dylib 0x00000001e3e43ea8 abort_message + 132
4 libc++abi.dylib 0x00000001e3e4406c default_terminate_handler+ 8300 () + 316
5 libobjc.A.dylib 0x00000001e3e60940 _objc_terminate+ 35136 () + 124
6 CasualPM 0x0000000104a06fd8 _hidden#13772_ + 1109976 (__hidden#13780_:179)
7 libc++abi.dylib 0x00000001e3e50ff0 std::__terminate(void (*)+ 61424 ()) + 16
8 libc++abi.dylib 0x00000001e3e51088 std::terminate+ 61576 () + 88
9 libdispatch.dylib 0x00000001e459a870 _dispatch_client_callout + 36
10 libdispatch.dylib 0x00000001e45a8c28 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1064
11 CoreFoundation 0x00000001e4b61748 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
12 CoreFoundation 0x00000001e4b5f3e0 __CFRunLoopRun + 1976
13 CoreFoundation 0x00000001e4a98430 CFRunLoopRunSpecific + 436
14 Foundation 0x00000001e5519e84 -[NSRunLoop+ 32388 (NSRunLoop) runMode:beforeDate:] + 300
15 Foundation 0x00000001e5519cf4 -[NSRunLoop+ 31988 (NSRunLoop) runUntilDate:] + 88
16 CasualPM 0x0000000104a203f4 _hidden#14662_ + 1213428 (__hidden#14672_:30)
17 CasualPM 0x00000001048fc9a8 _hidden#2_ + 18856 (__hidden#18_:55)
18 UIKitCore 0x00000002108cc350 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 408
19 UIKitCore 0x00000002108cda8c -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3340
20 UIKitCore 0x00000002108d33c8 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1776
21 UIKitCore 0x00000002110f200c __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 784
22 UIKitCore 0x00000002110eec9c +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 160
23 UIKitCore 0x00000002110f1c88 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 240
24 UIKitCore 0x00000002110f24c8 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 724
25 UIKitCore 0x00000002110b3084 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 296
26 UIKitCore 0x00000002110b2f0c -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 432
27 UIKitCore 0x00000002110f3f8c __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 220
28 UIKitCore 0x00000002110f4a7c _performActionsWithDelayForTransitionContext + 112
29 UIKitCore 0x00000002110f3e44 -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 248
30 UIKitCore 0x00000002110ee348 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 368
31 UIKitCore 0x00000002108d1854 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 540
32 UIKitCore 0x0000000210903704 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 364
33 FrontBoardServices 0x00000001e75fafa0 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 444
34 FrontBoardServices 0x00000001e7605d6c __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 260
35 FrontBoardServices 0x00000001e7605460 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 64
36 libdispatch.dylib 0x00000001e459a85c _dispatch_client_callout + 16
37 libdispatch.dylib 0x00000001e459fe90 _dispatch_block_invoke_direct$VARIANT$mp + 224
38 FrontBoardServices 0x00000001e7639a14 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
39 FrontBoardServices 0x00000001e76396a0 -[FBSSerialQueue _performNext] + 416
40 FrontBoardServices 0x00000001e7639cbc -[FBSSerialQueue _performNextFromRunLoopSource] + 56
41 CoreFoundation 0x00000001e4b61b4c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
42 CoreFoundation 0x00000001e4b61acc __CFRunLoopDoSource0 + 88
43 CoreFoundation 0x00000001e4b613a4 __CFRunLoopDoSources0 + 176
44 CoreFoundation 0x00000001e4b5f044 __CFRunLoopRun + 1052
45 CoreFoundation 0x00000001e4a98430 CFRunLoopRunSpecific + 436
46 GraphicsServices 0x00000001e6dc7548 GSEventRunModal + 100
47 UIKitCore 0x00000002108d51e0 UIApplicationMain + 212
48 CasualPM 0x00000001048fca68 main + 19048 (__hidden#21_:14)
49 libdyld.dylib 0x00000001e460cfa8 start + 4

Thread 1:
0 libsystem_pthread.dylib 0x00000001e47d5368 start_wqthread + 0

Thread 2:
0 libsystem_pthread.dylib 0x00000001e47d5368 start_wqthread + 0

Thread 3 name: Dispatch queue: Error API queue (QOS: UTILITY)
Thread 3:
0 libsystem_kernel.dylib 0x00000001e47589a0 __semwait_signal + 8
1 libsystem_c.dylib 0x00000001e4664c4c nanosleep + 212
2 Foundation 0x00000001e562a380 +[NSThread sleepForTimeInterval:] + 136
3 Foundation 0x00000001e5547468 -[__NSOperationInternal _start:] + 844
4 Foundation 0x00000001e5608fb4 __NSOQSchedule_f + 272
5 libdispatch.dylib 0x00000001e459a8a8 _dispatch_call_block_and_release + 24
6 libdispatch.dylib 0x00000001e459a85c _dispatch_client_callout + 16
7 libdispatch.dylib 0x00000001e459f8a0 _dispatch_continuation_pop$VARIANT$mp + 412
8 libdispatch.dylib 0x00000001e459ef54 _dispatch_async_redirect_invoke + 600
9 libdispatch.dylib 0x00000001e45abcd4 _dispatch_root_queue_drain + 372
10 libdispatch.dylib 0x00000001e45ac590 _dispatch_worker_thread2 + 128
11 libsystem_pthread.dylib 0x00000001e47d55c0 _pthread_wqthread + 480
12 libsystem_pthread.dylib 0x00000001e47d536c start_wqthread + 4

Thread 4:
0 libsystem_pthread.dylib 0x00000001e47d5368 start_wqthread + 0

Thread 5:
0 libsystem_pthread.dylib 0x00000001e47d5368 start_wqthread + 0

Thread 6 name: com.apple.uikit.eventfetch-thread
Thread 6:
0 libsystem_kernel.dylib 0x00000001e4736328 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x00000001e47361a0 mach_msg + 72
2 CoreFoundation 0x00000001e4b61538 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x00000001e4b5f1a8 __CFRunLoopRun + 1408
4 CoreFoundation 0x00000001e4a98430 CFRunLoopRunSpecific + 436
5 Foundation 0x00000001e5519e84 -[NSRunLoop+ 32388 (NSRunLoop) runMode:beforeDate:] + 300
6 Foundation 0x00000001e5519cf4 -[NSRunLoop+ 31988 (NSRunLoop) runUntilDate:] + 88
7 UIKitCore 0x000000021083274c -[UIEventFetcher threadMain] + 136
8 Foundation 0x00000001e562b064 __NSThread__start__ + 1040
9 libsystem_pthread.dylib 0x00000001e47d65a4 _pthread_body + 132
10 libsystem_pthread.dylib 0x00000001e47d64f8 _pthread_start + 48
11 libsystem_pthread.dylib 0x00000001e47d5374 thread_start + 4

Thread 7 name: JavaScriptCore bmalloc scavenger
Thread 7:
0 libsystem_kernel.dylib 0x00000001e4758484 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x00000001e47d909c _pthread_cond_wait$VARIANT$mp + 636
2 libc++.1.dylib 0x00000001e3deef10 std::__1::condition_variable::__do_timed_wait+ 32528 (std::__1::unique_lock&, std::__1::chrono::time_point > >) + 96
3 JavaScriptCore 0x00000001ec84e28c std::__1::cv_status std::__1::condition_variable::wait_until > >+ 1565324 (std::__1::unique_lock&, std::__1::chrono::time_point > > const&) + 124
4 JavaScriptCore 0x00000001ec84e130 std::__1::cv_status std::__1::condition_variable_any::wait_until, std::__1::chrono::steady_clock, std::__1::chrono::duration > >+ 1564976 (std::__1::unique_lock&, std::__1::chrono::time_point > > const&) + 112
5 JavaScriptCore 0x00000001ec84cda0 bmalloc::Scavenger::threadRunLoop+ 1559968 () + 296
6 JavaScriptCore 0x00000001ec84c458 bmalloc::Scavenger::threadEntryPoint+ 1557592 (bmalloc::Scavenger) + 12
7 JavaScriptCore 0x00000001ec84df0c void
std::__1::__thread_proxy >, void ()(bmalloc::Scavenger), bmalloc::Scavenger> >+ 1564428 (void) + 44
8 libsystem_pthread.dylib 0x00000001e47d65a4 _pthread_body + 132
9 libsystem_pthread.dylib 0x00000001e47d64f8 _pthread_start + 48
10 libsystem_pthread.dylib 0x00000001e47d5374 thread_start + 4

Thread 8 name: WebThread
Thread 8:
0 libsystem_kernel.dylib 0x00000001e4736328 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x00000001e47361a0 mach_msg + 72
2 CoreFoundation 0x00000001e4b61538 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x00000001e4b5f1a8 __CFRunLoopRun + 1408
4 CoreFoundation 0x00000001e4a98430 CFRunLoopRunSpecific + 436
5 WebCore 0x00000001edd61f4c RunWebThread+ 274252 (void*) + 592
6 libsystem_pthread.dylib 0x00000001e47d65a4 _pthread_body + 132
7 libsystem_pthread.dylib 0x00000001e47d64f8 _pthread_start + 48
8 libsystem_pthread.dylib 0x00000001e47d5374 thread_start + 4

Thread 9 name: WTF::AutomaticThread
Thread 9:
0 libsystem_kernel.dylib 0x00000001e4758484 __psynch_cvwait + 8
1 libsystem_pthread.dylib 0x00000001e47d909c _pthread_cond_wait$VARIANT$mp + 636
2 JavaScriptCore 0x00000001ec83a88c WTF::ThreadCondition::timedWait+ 1484940 (WTF::Mutex&, WTF::WallTime) + 148
3 JavaScriptCore 0x00000001ec82698c WTF::ParkingLot::parkConditionallyImpl(void const, WTF::ScopedLambda 4 JavaScriptCore 0x00000001ec80b520 bool WTF::Condition::waitUntil+ 1291552 (WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 184
5 JavaScriptCore 0x00000001ec80b8c0 WTF::Function::call+ 1292480 () + 216
6 JavaScriptCore 0x00000001ec838b3c WTF::Thread::entryPoint+ 1477436 (WTF::Thread::NewThreadContext
) + 256
7 JavaScriptCore 0x00000001ec6d9630 WTF::wtfThreadEntryPoint+ 38448 (void*) + 12
8 libsystem_pthread.dylib 0x00000001e47d65a4 _pthread_body + 132
9 libsystem_pthread.dylib 0x00000001e47d64f8 _pthread_start + 48
10 libsystem_pthread.dylib 0x00000001e47d5374 thread_start + 4

Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000000000000 x3: 0x0000000283d80137
x4: 0x00000001e3e54b41 x5: 0x000000016b503fa0 x6: 0x000000000000006e x7: 0xffffffffffffffec
x8: 0x0000000000000800 x9: 0x00000001e47dbe2c x10: 0x00000001e47d73a0 x11: 0x0000000000000003
x12: 0x0000000000000001 x13: 0x0000000000000000 x14: 0x0000000000000010 x15: 0x00000000000007fb
x16: 0x0000000000000148 x17: 0x0000000000000000 x18: 0x0000000000000000 x19: 0x0000000000000006
x20: 0x000000021cd310c0 x21: 0x000000016b503fa0 x22: 0x0000000000000303 x23: 0x000000021cd311a0
x24: 0x000000021cd311a0 x25: 0x0000000000000000 x26: 0x0000000044000000 x27: 0x00000002806c5240
x28: 0x0000000002ffffff fp: 0x000000016b503f00 lr: 0x00000001e47d7520
sp: 0x000000016b503ed0 pc: 0x00000001e475867c cpsr: 0x00000000

anybody could give me a clue of what could go wrong?

Locked 📦Bundler

Most helpful comment

Hello everyone! A new release of metro, 0.38.3, has been released and it should fix this issue. Since RN 0.56.0 depends on metro version

    "metro": "^0.38.1",
    "metro-babel-register": "^0.38.1",
    "metro-core": "^0.38.1",
    "metro-memory-fs": "^0.38.1",

This means that to apply the fix you would simply need to remove the node_modules (and if they're using yarn.lock you'll need to also clean metro from the lock file) and reinstall.

Or

yarn upgrade [email protected] will update all the dependencies too !

Thanks @kelset @rafeca ❤️ 🎉

All 93 comments

confirmed. it is crashing with message:
Unhandled JS Exception: Can't find variable: regeneratorRuntime

Can you see if moving these two lines:

const ReactNativeVersionCheck = require('ReactNativeVersionCheck');
ReactNativeVersionCheck.checkVersions();

in InitializeCore

to be below the timerSetup fixes this crash?

@TheSavior moved down under line defineLazyTimer('cancelIdleCallback');still got same issue:
Unhandled JS Exception: Can't find variable: regeneratorRuntime

Try moving the polyfill block: polyfillGlobal('regeneratorRuntime', () => { above the polyfillGlobal('Promise', () => require('Promise')); line.

The reason I'm thinking we should be mucking around here is because I ran into this myself a while back and the issue was that something was crashing but the exception handler required regeneratorRuntime but it hadn't been polyfilled yet.

Do you have a stack trace from the exception?

Can you repro with a debugger statement and step around?

@TheSavior it doesn't help. here is what the file is looks like now:

// Set up regenerator.
polyfillGlobal('regeneratorRuntime', () => {
  // The require just sets up the global, so make sure when we first
  // invoke it the global does not exist
  delete global.regeneratorRuntime;
  /* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an
   * error found when Flow v0.54 was deployed. To see the error delete this
   * comment and run Flow. */
  require('regenerator-runtime/runtime');
  return global.regeneratorRuntime;
});

// Set up Promise
// The native Promise implementation throws the following error:
// ERROR: Event loop not supported.
polyfillGlobal('Promise', () => require('Promise'));

// Set up timers
const defineLazyTimer = name => {
  polyfillGlobal(name, () => require('JSTimers')[name]);
};
defineLazyTimer('setTimeout');
defineLazyTimer('setInterval');
defineLazyTimer('setImmediate');
defineLazyTimer('clearTimeout');
defineLazyTimer('clearInterval');
defineLazyTimer('clearImmediate');
defineLazyTimer('requestAnimationFrame');
defineLazyTimer('cancelAnimationFrame');
defineLazyTimer('requestIdleCallback');
defineLazyTimer('cancelIdleCallback');

// Check for compatibility between the JS and native code
const ReactNativeVersionCheck = require('ReactNativeVersionCheck');
ReactNativeVersionCheck.checkVersions();

exactly same issue: Unhandled JS Exception: Can't find variable: regeneratorRuntime (/Users/xxx/Library/Developer/CoreSimulator/Devices/25D07A35-FD85-44FA-AD03-18D47AF6F3DA/data/Containers/Bundle/Application/xxx/xxx/main.jsbundle:326)

PS: No stack trace, as far I can get this message from device log, there is no trace. even try-catch doesn't help. I can't debug as far it early initiation. could you suggest the way to debug?

Can you repro on a new project and provide easy repro steps for someone else to take a look?

@TheSavior
the funny thing: empty project (created by react-native init and upgraded to rc.2 - works ok. just verified. Also I tried to make production build for RNTesterproject, which also is fine.

I would try to add some portions of code from my project until it breaks...
will let you know my findings

@eshikerya same issue here. Any updates on your side?

very strange is going on here. stable code under 55.4 looks wierd now. removed any imports and have just simple screen with fake text, then adding line by line until it breaks, then dig deeper. regular fetch is working, promise is working, redux is working. get stuck it level where im showing login/error screen. not crashing but show empty screen, works under debug build, but not under release. going deeper. will share my finding when i find something...

@eshikerya on my app it even crashes on the device started on debug from xcode. It runs on the simulator however.

anything in console? which issue causing it? mine is Unhandled JS Exception: Can't find variable: regeneratorRuntime

@eshikerya after doing

watchman watch-del-all
rm -rf ./node_modules
rm -rf $TMPDIR/react-*
yarn install

and reinstall the app on ios, it works no on DEBUG, i'll check now release...

@eshikerya ok, can confirm it also crashes on RELEASE build with the same error:

Can't find variable: regeneratorRuntime (/var/containers/Bundle/Application/C4B19D4D-A27A-4B0F-B024-926777EFDA00/Velo-Mittwoch-staging.app/main.jsbundle:789)

i am using redux-saga which (i think) uses regenerator-runtime. Maybe it just needs to be installed because of the changes in babel 7? it makes no sense however, that it works on debug build...

Edit: i found out that i have regenerator-runtime twice: 0.11 (from react-native) and 0.10 (indirectly from react-native-firebase (react-native-firebase --> opencollective --> babel-polyfill --> [email protected])

maybe that's a clue? can you check your yarn.lock?

Edit: ok no, we already had both regenerator-runtimes in the previous react-native version...

Android release version fail too:

06-22 17:31:37.972 27529 27632 E AndroidRuntime: Caused by: com.facebook.jni.CppException: Can't find variable: Promise (index.android.bundle:817)

I found a workaround. I change my index.js:

import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('xxxxapp', () => App);

by

import { AppRegistry } from 'react-native';
AppRegistry.registerComponent('xxxxapp', () => require('./App').default);

and its work on release configuration

@francisco-sanchez-molina can confirm that this seems to work on android and ios!

but this means that the error occures on usage on generators in the app code. Do you use generators? Then, shouldn't we be able to import the polyfill before AppRegistry?

You changed from import to require and also inclined it. What if you only do one of those things?

import { AppRegistry } from 'react-native';
const App = require(‘./App’).default;
AppRegistry.registerComponent('xxxxapp', () => App);

@TheSavior I test it, and this version

import { AppRegistry } from 'react-native';

const App = require('./App').default;

AppRegistry.registerComponent('newbalanceapp', () => App);

fails :/

@macrozone I do not use generators

@TheSavior rollback from where I began and changed index.js for this:

import { AppRegistry } from 'react-native';
// import App from './src/bootstrap';

AppRegistry.registerComponent('App', () => require('./src/bootstrap').default);

now it works in Production build, even I use generators... hm...

Are you able to repro this on a brand new project created with the latest RC via react-native init?

Coming up with a minimal repro will help us track down the problem.

goes through some seeds on react-native awesome pages, those I could quickly upgrade to latest RC - works as expected. project created by react-native initafter some magic as yarn upgrade babel-preset-react-native@next - works as expected. have no idea what is causing the issue... will dig later...

@TheSavior here is a reproduction. it indeed happens when you use generators:

https://github.com/macrozone/react-native-056-crash-on-production-reproduction

it s fresh react-native init project, upgraded to 0.56-rc.2

I just added redux and redux-saga and initialized a store how you would normally do with redux and redux-saga.

on production it crashes with Unhandled JS Exception: Can't find variable: regeneratorRuntime

EDIT: It's even simple to reproduce it. Just add this line in App.js:

function* crashyMcCrashface() {}

the bare existence of a generator function will crash the app on production

You can also reproduce issue with the following code console.log(Promise);

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
  android:
    'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

console.log(Promise);

type Props = {};
export default class App extends Component<Props> {
  render() {

I have problems with missing fetch, WebSocket and alert.

Can't release my app since I have coded it using babel 7 babel-plugin-transform-optional-chaining so completely blocked by this.

fetch is not found globally and no fetcher passed, to fix pass a fetch for
your environment like https://www.npmjs.com/package/node-fetch.

For example:
import fetch from 'node-fetch';
import { createHttpLink } from 'apollo-link-http';

const link = createHttpLink({ uri: '/graphql', fetch: fetch }); (/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:419)
E0626 02:08:59.256019 1833955328 JSCHelpers.cpp:146] Got JS Stack: checkFetcher@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:419:1370
a@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:418:1091
t@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:418:2806
default@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:364:2438
/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:363:355
c@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:2:809
/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:313:158
c@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:2:809
/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:312:144
c@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:2:809
/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:12:77
c@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:2:809
i@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:2:381
global code@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:1404:8
E0626 02:08:59.258453 1833955328 JSCHelpers.cpp:140] Got JS Exception: Exception calling object as function: Module AppRegistry is not a registered callable module (calling runApplication) (<unknown file>:14)
E0626 02:08:59.258481 1833955328 JSCHelpers.cpp:146] Got JS Stack: exports@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:14:308
value@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:18:3100
/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:18:824
value@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:18:2510
value@/var/containers/Bundle/Application/71471209-7389-4793-B40E-67DDE971B781/Hablemos.app/main.jsbundle:18:796
value@[native code]

So, I did a bit of digging and, based on the clues and what @TheSavior was saying about regeneratorRuntime used "before being ready", I found this issue on the redux-saga repository which seems to contain some extra details which may be helpful in finding a solution (which I now believe lies in a custom config of the package.json).

As you may notice regeneratorRuntime is used before being required. This is an issue between regenerator-transform and react-native preset. The import for the regeneratorRuntime is inserted by you version of react-native preset. Newer version should not behave like this, as this commit removed the inserting transform.

src: https://github.com/redux-saga/redux-saga/issues/1218

(ofc I may be wrong)


@gaston it seems that you have a different issue related to the configuration of your babel plugins, I suggest you read this issue and this section of the docs for Babel 7.

@kelset I am not sure. In #19806 @viniychuk mentions but my error is with "fetch" variable so that is the same problem I have and that issue was closed in favor of this one. Where do you think my problem resides? Have no idea how to fix it.

19806? The link is to #19789

and

Where do you think my problem resides? Have no idea how to fix it.

I just told you

related to the configuration of your babel plugins, I suggest you read this issue and this section of the docs for Babel 7.

I met the same problem.

After changing code on

AppRegistry.registerComponent('App', () => require('./src/bootstrap').default);

And after moving Sentry (error tracker) from index.js to ./src/bootstrap our problem with regeneratorRuntime gone. So better to not import any libs in the index.js which use regeneratorRuntime.

But after solving regeneratorRuntime problem we met with undefined is not an object error. With minify=false in production build was detected a problem with _TabRouter in [email protected]. After upgrading on [email protected] production bundle starts without errors.

@kelset 19806. But I am not using decorators and I have no custom babelrc.

@gaston I still miss where I linked 19806 but w/e. I still think your issue is different, so if you think 19789 is not related please open a new issue following the template.


@nodkz uh interesting, another evidence about this issue being related to regeneratorRuntime "starting" before it should.

@kelset: a clean 0.56 project without regeneratorRuntime fail when you add console.log(Promise);

Might be related to this problem: https://github.com/babel/babel/pull/5474

Oh nice catch @francisco-sanchez-molina, seems like it! But that PR was merged into babel 7 since beta.3, am I right? 🤔

Yes, I have also seen that react-native uses commonjs :/

I get Unhandled JS Exception: Can't find variable: window since the first RC

@markholland that's probably unrelated. Maybe this comes from redux-devtools code, which usually works by attaching to "window"

@macrozone @markholland me too, same window error on release.

I'm seeing Unhandled JS Exception: Can't find variable: setTimeout on RC 4. It's only occurring when I build on an iOS device. When running in the simulator everything works perfectly.

Same Can't find variable: window only in Release mode.

After digging it and manually remove the code which uses window variable, another Can't find variable: fetch error occurs.

0.55.x and Debug mode in 0.56.0 works fine.

👋 folks - a couple of quick things:

1) In our app we had to add this babel-bridge and enforce yarn resolutions in order to make sure that everything was being bundled properly. Have you tried using them? I feel these issues are related to something not "using" babel7 🤔

2) We will release 0.56.0 today (if nothing goes wrong) in order to increase the surface of devs using it, and hopefully lead to faster fixes for issues like this. We know it's not ideal but hopefully for 0.56.1 this will be completely fixed (if it's not fixable via point 1)

@kelset thanks! Here are some details of my experience and workaround, hope this helps:

I am using babel-preset-react-native@^5.0.1 with a .babelrc file that looks like:

{
  "presets": ["react-native"]
}

I found the offending line was a setTimeout call in Redux Persist. You can see the offending line in this source file, line 89. Nothing looks out of place to me in the way Redux Persist uses setTimeout.

Downgrading Redux Persist temporarily avoids this issue for me. I can use a setTimeout in my application anywhere else, so this appears to be a problem with imported modules only.

Uhm I guess you use v5? On our prod app we are using v4 so maybe that's why I don't have this issue.

That said maybe it's worth opening a parallel issue on their repo.

PS: have you tried using [email protected] (explicit & fixed)?

Still not working for me in stable 56. window is missing. Compiling with xCode 10 beta 2

E0704 14:17:49.259058 1844490240 JSCHelpers.cpp:140] Got JS Exception: Can't find variable: window (/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:479)
E0704 14:17:49.259202 1844490240 JSCHelpers.cpp:146] Got JS Stack: /var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:479:634
/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:479:1437
/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:479:1450
/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:479:10727
c@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:2:809
/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:478:178
c@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:2:809
/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:392:11556
c@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:2:809
/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:391:211
c@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:2:809
/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:328:158
c@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:2:809
/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:327:144
c@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:2:809
/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:12:133
c@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:2:809
i@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:2:381
global code@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:1492:8
E0704 14:17:49.261899 1844490240 JSCHelpers.cpp:140] Got JS Exception: Exception calling object as function: Module AppRegistry is not a registered callable module (calling runApplication) (<unknown file>:14)
E0704 14:17:49.261939 1844490240 JSCHelpers.cpp:146] Got JS Stack: exports@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:14:308
value@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:18:3100
/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:18:824
value@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:18:2510
value@/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:18:796
value@[native code]
2018-07-04 14:17:49.267 [fatal][tid:main] Unhandled JS Exception: Can't find variable: window (/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:479)
2018-07-04 14:17:49.268228-0300 Hablemos[2812:618239] Unhandled JS Exception: Can't find variable: window (/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:479)
2018-07-04 14:17:49.268451-0300 Hablemos[2812:618239] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Can't find variable: window (/var/containers/Bundle/Application/956E12F1-1E29-4B45-8A83-6B4AF662F874/Hablemos.app/main.jsbundle:479)', reason: 'Unhandled JS Exception: Can't find variable: window (/var/containers/Bundle...'
*** First throw call stack:
(0x1b8073960 0x1b732452c 0x1022e5d94 0x1022d1d1c 0x102a75384 0x102a75338 0x102a7a1e4 0x1b8025748 0x1b80233e0 0x1b7f5c430 0x1ba28b548 0x1e3ddd1e0 0x10223ffe0 0x1b7ad0fa8)
libc++abi.dylib: terminating with uncaught exception of type NSException

I see the following packages requiring babel-core@^6.26.0

├─ [email protected] (required by [email protected])
│  ├─ babel-core@^6.26.0
│  ├─ babel-runtime@^6.26.0
├─ [email protected] (required by react-native 56)
│  ├─ babel-core@^6.7.2
├─ [email protected] (required by [email protected])
│  ├─ babel-core@^6.24.1

My error is happening when node_modules/react-native/local-cli/link/link.js:41:91 runs. If I change my node_modules/react-native/scripts/react-native-xcode.sh call to node_modules/react-native/local-cli/cli.js bundle to call babel-node instead of node it actually works. Aka its babel being incorrect while trying to make the production bundle and not something in my actual source

update to 0.56.0, when run android on release mode, app crash .
java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Can't find variable: Promise

i just found that, if using promise outside first Component class, on release mode it crash.

// run error: Can't find variable: Promise
let test = Promise.reject(new Error('registerApp required.'));
test.then(() => {
    console.log('test');
});

type Props = {};
export default class App extends Component<Props> {
  constructor(props) {
    super(props);

      // run ok
      // let test = Promise.reject(new Error('registerApp required.'));
      // test.then(() => {
      //     console.log('test');
      // });
  }
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>Welcome to React Native!</Text>
        <Text style={styles.instructions}>To get started, edit App.js</Text>
        <Text style={styles.instructions}>{instructions}</Text>
      </View>
    );
  }
}

Reproducible Demo

https://snack.expo.io/r1tfsO2fX

"dependencies": {
    "react": "16.4.1",
    "react-native": "0.56.0"
  },
  "devDependencies": {
    "babel-jest": "23.2.0",
    "babel-preset-react-native": "^5",
    "jest": "23.3.0",
    "react-test-renderer": "16.4.1"
  },
  "jest": {
    "preset": "react-native"
  }

I had the same crash "can't find variable: xyz", but only when building directly from XCode. I investigated the "missing variables" one by one and found that they all where unused generator functions in my Redux Sagas. All generator functions that where indeed called, either from other generators or from the saga watchers, worked fine.

After remarking the unused generator functions everything works great. I thought that this might me a new XCode thing for hunting down dead code, but it would be an odd way to present the dead code snippets by crashing.

When can we expect a fix for this issue? It kinda blocks our release :(

Same issue here (regeneratorRuntime is not defined), but I think the reason is different, I think the issue comes from react-native cli directly. Because I've been putting logs inside the commands and they seem to crash before my code.

When I log here before calling buildBundle I see the log.
https://github.com/facebook/react-native/blob/master/local-cli/bundle/bundle.js#L23

But buildBundle is an async function, so I would need the cli to have setup babel-register correctly, however it is not well setup which explains why it crashes. My project is kindof complex (workspaces, ...) and I have no idea how it could interfere with it. I'm still digging.

When I'm just starting the server in dev-mode, everything is working properly.
(When I setup a new project everything is working properly.
When I paste my complexes node_modules folder into the new_project it's also working.)

When I run react-native bundle --platform android --dev false --entry-file index.js --bundle-output lol.js --verbose --reset-cache => regeneratorRuntime is not defined

@kelset

EDIT: I have been able to bundle my code by adding require('@babel/polyfill'); in cli.js and adding polyfill to my dependencies. This is not a good fix, however it might point us in the right direction to find the bug

EDIT 2:
Commenting here changes the error to show that it comes from here:

node_modules/react-native/local-cli/link/link.js:41
var linkDependency=function(){var _ref=_asyncToGenerator(regeneratorRuntime.mark(function _callee(platforms,project,dependency){var params;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return(
                                                         ^

ReferenceError: regeneratorRuntime is not defined

EDIT 3:
Using my first edit to build the app allow the build to succeed but the app then crash on start with

java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Can't find variable: Promise (index.android.bundle:118)

Quick-side update, as I just wrote here please ensure that you are using all the babel related deps as fixed to 7.0.0-beta.47, along 5.0.2 of the preset, like so:

"devDependencies": {
    "@babel/core": "7.0.0-beta.47",
    // example of another babel plugin
    "@babel/plugin-proposal-decorators": "7.0.0-beta.47",
    "babel-preset-react-native": "5.0.2",
  },

Using generators in my app as well and enabling remote debugging works fine. Guessing V8 propertly uses regeneratorRuntime while JavaScriptCore doesn't. The remote debugger however throws this error on startup but it doesn't crash the app: Uncaught (in promise) Error: Unknown named module: 'MessageQueue'

Otherwise without app crashes with the following errors on startup:

  • Can't find variable: self [in random.browser.js:1:18] (Saw someone have the same issue yesterday)
  • Cannot find variable Promise

Okay, I found a way to replicate my bug,

If you init a new react native project with react-native init and then you replace your .babelrc with babel.config.js, eg:

module.exports = (api) => {
  api.cache(true);
  return {
    presets: ['react-native'],
  };
};

Your bundle command will fail with regeneratorRuntime is not defined

@kelset

EDIT: we might want to split this issue in two, because some people here are having issue when bundling and some people are having issues when running the app

EDIT 2: replacing babel.config.js by .babelrc.js fixed my issue.
I find the docs very confusing because they clearly say that we should use babel.config.js, but we can see that it will not merge it's config with the projects below it (eg RN I guess).
https://babeljs.io/docs/en/next/configuration

So, after a whole day of fun 😅, I've finally got both development and production working for iOS and android 🎉 , but I think we need one main fix: initializeCore is never required on android release build, at least with my config, so this explain why all the polyfills such as Promise and timers are missing, I got my release build to work after adding require('react-native/Libraries/Core/InitializeCore'); on the entry point. I've encountered most of the issues from this thread and got around all of them so if anyone still needs help, please ping me.

I'll dig tomorrow to understand why it's not being required by metro as it should..

@Titozzz I'll take you up on your offer... I'm currently getting the following issue:

Unhandled JS Exception: undefined is not an object (evaluating 'babelHelpers.interopRequireDefault(i(a[0])).default.BehaviorSubject')

This happens on release only. Source maps show it's from apollo-link-state but i think it's just a generic babel issue. Any ideas?

@Titozzz thanks for the hint, I'm not sure if I understood you correctly, but I tried to add
require('react-native/Libraries/Core/InitializeCore');
to the very beginning to my index.js and it didn't change anything on release mode for Android. I tried cleaning and deleting and creating it from scratch — doesn't make any difference..

edit: forgot to say that the actual issue is in that same "Variable not find: Promise"

Update, I fixed the above issue with some updating of npm modules and clearing my cache. I'm still getting more errors, one of them being:

Unhandled JS Exception: g is not a function. (In 'g(t,e,void 0,t,null,n)

in const setItem = Promise.promisify(AsyncStorage.setItem); where Promise is the Bluebird promise

Another update, I fixed the above by manually requiring the right file from the library, but I feel like there's an underlying babel issue still here. Anyway, now I'm getting Unhandled JS Exception: Can't find variable: regeneratorRuntime after following all of the above advice.

What about adding the actual polyfill?

require('babel-polyfill');

update

I included it and got another error message:

Unhandled JS Exception: t is not a function. (In 't(i?function(){('function'==typeof n?n:Function(n)).apply(this,u)}:n,e)', 't' is undefined)

@birkir tried that. Doesn't help at all, like if I weren't including it. Cleaned cached, deleted the build folder on Android — same result.

@viniychuk this fixed it for me:

require('react-native/lib/InitializeJavaScriptAppEngine');

@birkir no luck.

java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Can't find variable: Promise (index.android.bundle:355)
        at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:22)
        at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:170)
        at com.facebook.react.bridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:525)
        at com.facebook.react.bridge.CatalystInstanceImpl.access$1000(CatalystInstanceImpl.java:39)
        at com.facebook.react.bridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:541)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
        at android.os.Looper.loop(Looper.java:158)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
        at java.lang.Thread.run(Thread.java:818)
     Caused by: com.facebook.react.devsupport.JSException: Can't find variable: Promise (index.android.bundle:355)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
        at android.os.Looper.loop(Looper.java:158) 
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) 
        at java.lang.Thread.run(Thread.java:818) 
     Caused by: com.facebook.jni.CppException: Can't find variable: Promise (index.android.bundle:355)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
        at android.os.Handler.handleCallback(Handler.java:739) 
        at android.os.Handler.dispatchMessage(Handler.java:95) 
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) 
        at android.os.Looper.loop(Looper.java:158) 
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) 
        at java.lang.Thread.run(Thread.java:818) 

Ahh ok. I'm using typescript and it works for me, as the entrypoint is only to load App.ts, so ts polyfills the rest

@viniychuk Right now my app.js starts with

import './polyfills';

and polyfills.android.js contains

// symbol polyfills
global.Symbol = require('core-js/es6/symbol');
require('core-js/fn/symbol/iterator');

// collection fn polyfills
require('core-js/fn/map');
require('core-js/fn/set');
require('core-js/fn/array/find');

require('react-native/Libraries/Core/InitializeCore');

if (!global.Intl) {
  // eslint-disable-next-line global-require
  require('intl');
  // eslint-disable-next-line global-require
  require('intl/locale-data/jsonp/fr-FR');
  // eslint-disable-next-line global-require
  require('intl/locale-data/jsonp/en-GB');
}

Please note that you should not add core-js as a dependency since it is already here for RN.

Ok so the reason I'm getting Promise is not a variable comes from here: https://github.com/facebook/react-native/blob/a93e281428f47ba355ba79cda3e98ca7da677636/Libraries/BatchedBridge/NativeModules.js#L89

I have a native module function that I call in the global scope :

  FCM.createNotificationChannel({
    id: 'default',
    name: 'Default',
    description: "Brigad's default notification channel",
    priority: 'high',
  });

I don't know why, but in release mode the bridge generate the method to quickly, before adding the polyfills...

I can fix my app by putting the code above in a init function and calling it during the init of my app but it's not very satisfaying

Still digging ⛑ 😫

Hi, i have this problem on production version
WARNING: Logging before InitGoogleLogging() is written to STDERR E0711 10:36:21.700479 116854784 JSCHelpers.cpp:140] Got JS Exception: Can't find variable: self (/Users/alexandre/Library/Developer/CoreSimulator/Devices/751E1AC7-5310-4523-9AA4-2AC352090EC1/data/Containers/Bundle/Application/E2E29239-B6A9-48AD-85B9-18058A049DEB/whaller.app/main.jsbundle:537) E0711 10:36:21.700690 116854784 JSCHelpers.cpp:146] Got JS Stack: /Users/alexandre/Library/Developer/CoreSimulator/Devices/751E1AC7-5310-4523-9AA4-2AC352090EC1/data/Containers/Bundle/Application/E2E29239-B6A9-48AD-85B9-18058A049DEB/whaller.app/main.jsbundle:537:12134 /Users/alexandre/Library/Developer/CoreSimulator/Devices/751E1AC7-5310-4523-9AA4-2AC352090EC1/data/Containers/Bundle/Application/E2E29239-B6A9-48AD-85B9-18058A049DEB/whaller.app/main.jsbundle:537:12137 c@/Users/alexandre/Library/Developer/CoreSimulator/Devices/751E1AC7-5310-4523-9AA4-2AC352090EC1/data/Containers/Bundle/Application/E2E29239-B6A9-48AD-85B9-18058A049DEB/whaller.app/main.jsbundle:2:809 /Users/alexandre/Library/Developer/CoreSimulator/Devices/751E1AC7-5310-4523-9AA4-2AC352090EC1/data/Containers/Bundle/Application/E2E29239-B6A9-48AD-85B9-18058A049DEB/whaller.app/main.jsbundle:536:133

Any ideas ?

@kelset // _Is this thread still the good place to discuss this ? Maybe we should transfer it to the metro repo._

I think I found the main issue I was facing, and why some people have problems and others don't. I've dug a lot into React-native and metro code and I've noticed a few incoherences.

I'm going to summarize the last 3 days of researching and issues I've had:

  • regeneratorRuntime not defined when bundling => use .babelrc.js instead of babel.config.js
  • Symbol error at runtime on android => polyfill with
// symbol polyfills
global.Symbol = require('core-js/es6/symbol');
require('core-js/fn/symbol/iterator');

// collection fn polyfills
require('core-js/fn/map');
require('core-js/fn/set');
require('core-js/fn/array/find');

  • Other error like Promise or setTimeout at runtime on android Release =>
    From my log, this is why I saw
    When using metro to serve the bundle in dev mode, InitializeCore.js is loaded first and everything is ~okay.
    When using react-native bundle (the command that runs when you build a release), InitializeCore.js is not the first file that get required, but instead it is required later, sometime during the generation of the bridge method, randomly (which is why if you are lucky or not using Promise // setTimeout early you'll be fine)
    iOS does not need all those polyfills which is why the issue is only detected on android in release mode.

My insight:
Metro does not add InitializeCore.js to the entry point when building the js bundle. I've logged here. The issue being that it takes options.runBeforeMainModule that defaults to [].
Maybe we could merge it with _this._opts.getModulesRunBeforeMainModule() which defaults to ['/node_modules/react-native/Libraries/Core/InitializeCore.js'].

I've tried to replace it with

runBeforeMainModule: [
            ...options.runBeforeMainModule,
            ..._this._opts.getModulesRunBeforeMainModule(),
          ],

and android was working in release 🎉

I'd like to get more insight from other people and feel free to ask any other question, thanks

Hey @Titozzz, thanks for the deep digging. I'll link your comment to some devs on the Metro team, but yeah probably it would be best to open an issue on the metro for the InitializeCore portion.

One more production build issue with babel helpers with 2 workarounds https://github.com/facebook/react-native/issues/20150

On [email protected] + [email protected] I get error: bundling failed: TypeError: Cannot read property 'bindings' of null. The solution according to this thread https://github.com/facebook/react-native/issues/20042 is to upgrade babel-preset-react-native to 5.0.0.

On [email protected] + [email protected] I get Failed to load bundle: Cannot read property 'throwIfClosureRequired' of undefined. The solution according to this thread https://github.com/facebook/react-native/issues/18962 is to downgrade babel-preset-react-native to 4.0.0.

This seems like a paradox. Trying to find that sweet spot of versions so my project works again. Any suggestions greatly appreciated. Thanks
🤔

@Titozzz

Thanks for the follow-up.

I'm still stuck on this point:

  • regeneratorRuntime not defined when bundling => use .babelrc.js instead of babel.config.js

I'm not convinced that's the solution. I'm using a static .babelrc. I've even gone so far as adding babel-polyfill to my dependencies and requiring it at the start. Still no dice.

@danieljvdm You can put w/e in your code, the cli is crashing before reaching your code. If you want to fix it the dirty way, have you tried adding babel/polyfill into cli.js (see my first edit here : https://github.com/facebook/react-native/issues/19827#issuecomment-403469997)

faced same issue, @Titozzz's solution worked like a charm

Is this being actively worked on? Is there an ETA for a fix?

This really feels like something that should have blocked this release, and if we can expect future versions of React Native to break something as basic as production builds, it removes a lot of confidence we will have in using React Native in the future.

Right now, we're faced with a choice of blocking a release for this to get fixed, reverting to 0.55 and exposing users to bugs that were fixed in 0.56, or (what wound up happening for me) using a hacky workaround that requires code restructuring. We're working on our first RN app and if I have to go to my boss and delay a release because of issues like this, it's a really bad look for RN and really hurts the chances we'll continue using it going forward.

Why aren't production build variants and runtime tests against them part of the release testing? How can I contribute some so that these sorts of issues are surfaced earlier and block future releases? Given that this issue was surfaced on a release candidate, why did the RC get promoted before this was fixed? Is production stability not a priority?

@EdwardDrapkin I have personally opted to fork 0.56 and rebase removing all babel and metro commits. After fixing some conflicts, it is working great.

Thanks for all the research @Titozzz. Honestly, I don't understand the technical complications involved in your solution but it works like a charm on both iOS and Android. Much appreciation for your help!

If you have a typescript setup this fix works well:

https://github.com/facebook/react-native/issues/19827#issuecomment-403957066

Make sure to put before everything else.

Unfortunately, your fix did not work for me @birkir

@EdwardDrapkin Of course they ran CI and did tests and it worked for them. It's been 4 month since the last release and honestly, I was expecting so many more things to go wrong.. You can already build working release with the fixes from this thread if you need it. If you want to follow the fix, @rafeca said he was gonna implent my fix directly into metro.

As to why they promoted to release with this issue opened, @kelset said they needed more feedback to understand the bug and that exactly what happened !
I know it can be frustrating when something you try to use is broken, but please remember that is it mostly open source people that do it on their free time.

If you need any help please post below :tada:

@Titozzz is right. I've spent days when upgrading to new versions in the past. This was a breeze and since it only breaks for release builds, a little harder to catch. Upgrading to 0.56.0 was the easiest of all the upgrades I've done in the past.

Cheers and thanks to all for helping!

Hello everyone! A new release of metro, 0.38.3, has been released and it should fix this issue. Since RN 0.56.0 depends on metro version

    "metro": "^0.38.1",
    "metro-babel-register": "^0.38.1",
    "metro-core": "^0.38.1",
    "metro-memory-fs": "^0.38.1",

This means that to apply the fix you would simply need to remove the node_modules (and if they're using yarn.lock you'll need to also clean metro from the lock file) and reinstall.

Or

yarn upgrade [email protected] will update all the dependencies too !

Thanks @kelset @rafeca ❤️ 🎉

@Titozzz im at the 0.56.0 version. But i still get this error.
my package.json

{
  "name": "MyAppName",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "apisauce": "^0.15.2",
    "bugsnag-react-native": "^2.10.0",
    "color": "^3.0.0",
    "lodash": "^4.17.10",
    "moment": "^2.22.2",
    "numeral": "^2.0.6",
    "react": "16.4.1",
    "react-native": "0.56.0",
    "react-native-flash-message": "^0.1.9",
    "react-native-iphone-x-helper": "^1.0.3",
    "react-native-modal": "^6.4.0",
    "react-native-orientation": "^3.1.3",
    "react-native-root-toast": "^3.0.1",
    "react-native-scrollable-tab-view": "^0.8.0",
    "react-native-vector-icons": "^4.6.0",
    "react-native-video": "^3.0.0",
    "react-native-video-controls": "^2.2.3",
    "react-navigation": "^2.6.2",
    "react-navigation-slide-from-right-transition": "^1.0.4",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-persist": "^5.10.0",
    "redux-saga": "^0.16.0"
  },
  "devDependencies": {
    "babel-jest": "23.2.0",
    "babel-preset-react-native": "^5",
    "jest": "23.3.0",
    "react-test-renderer": "16.4.1",
    "reactotron-react-native": "^2.0.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

@hungdev Are you sure you ran the upgrade command ? Which version of metro are you using right now ? (You can run yarn why metro to know)

@Titozzz I did not upgrade. I set up the new project.
Could you tell me how to get version of metro?

@hungdev can you create a small repo with the repro and post the link?

@hungdev If you set up your repo before we released the fix, you are probably running the wrong version of metro. Please run this step: yarn upgrade [email protected] even if you did not upgrade, it will make sure the dependencies are up to date. Or you can set up another new project.

i ran: yarn upgrade [email protected] in my project. But it still get same error.
But when i create an example and build release. It builds release fine.
I don't understand where is my error. Maybe i should create new project and copy source code to that.

@hungdev Can you paste your error trace here ? You did not specify what was your issue.

im using bugsnag to detect
screen shot 2018-07-16 at 8 00 58 pm

It seems to me that this should require a separate issue once it has been properly understood and there is a repro. I'm closing this issue as it seems that it fixed for most people, and again please open a new one with a repro once you understand where the issue lies @hungdev

Was this page helpful?
0 / 5 - 0 ratings