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

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_lockstd::__1::mutex&, std::__1::chrono::time_point<std::__1::chrono::system_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >) + 96 3 JavaScriptCore 0x00000001ec84e28c std::__1::cv_status std::__1::condition_variable::wait_until<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >+ 1565324 (std::__1::unique_lockstd::__1::mutex&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > > const&) + 124 4 JavaScriptCore 0x00000001ec84e130 std::__1::cv_status std::__1::condition_variable_any::wait_until<std::__1::unique_lockbmalloc::Mutex, std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >+ 1564976 (std::__1::unique_lockbmalloc::Mutex&, std::__1::chrono::time_point<std::__1::chrono::steady_clock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > > 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<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_deletestd::__1::__thread_struct >, 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<bool ()> const&, WTF::ScopedLambda<void + 1403276 ()> const&, WTF::TimeWithDynamicClockType const&) + 2004 4 JavaScriptCore 0x00000001ec80b520 bool WTF::Condition::waitUntilWTF::Lock+ 1291552 (WTF::Lock&, WTF::TimeWithDynamicClockType const&) + 184 5 JavaScriptCore 0x00000001ec80b8c0 WTF::Function<void ()>::CallableWrapper<WTF::AutomaticThread::start(WTF::AbstractLocker const&):šŸ˜’_0>::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?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 93 (12 by maintainers)

Most upvoted comments

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 react-native@0.56.0 will update all the dependencies too !

Thanks @kelset @rafeca ā¤ļø šŸŽ‰

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ā€¦

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

@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

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 babel-preset-react-native@5.0.2 (explicit & fixed)?

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() {

@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!

faced same issue, @Titozzzā€™s solution worked like a charm

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.

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 ā›‘ šŸ˜«

@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?

@markholland thatā€™s probably unrelated. Maybe this comes from redux-devtools code, which usually works by attaching to ā€œwindowā€

@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

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

@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 šŸŽ‰

Unfortunately, your fix did not work for me @birkir

@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.

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",
  },

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 react-navgation@1.5.12. After upgrading on react-navgation@2.5.5 production bundle starts without errors.