[0.87] Bootstrap Metro from InitializeCore until setup-env is graph-reachable#57551
Closed
zeyap wants to merge 1 commit into
Closed
[0.87] Bootstrap Metro from InitializeCore until setup-env is graph-reachable#57551zeyap wants to merge 1 commit into
zeyap wants to merge 1 commit into
Conversation
…eachable Summary: Fresh 0.87 projects redbox on launch with: Failed to call into JavaScript module method RCTDeviceEventEmitter.emit(). Module has not been registered as callable. Registered callable JavaScript modules (n = 1): AppRegistry. Core initialization never runs. Metro's `getModulesRunBeforeMainModule` (see metro/src/lib/getAppendScripts.js) only emits the run-before `__r()` call for a module that is *already present in the bundle graph*, and silently skips it otherwise. #57475 switched the run-before target from `Libraries/Core/InitializeCore` to `src/setup-env.js`. `InitializeCore` is reachable in the graph (imported by `Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js`), but `src/setup-env.js` is imported by nothing, so Metro skips it and core init never runs. The two modules are functionally identical (both call `setUpDefaultReactNativeEnvironment().default()`). Evidence (bundle tail): - setup-env target: `__r(0);` (broken) - InitializeCore target: `__r(110); __r(0);` (fixed) This is an INTERIM stopgap to unblock the 0.87 RC. It only changes the internal Metro bootstrap target back to `InitializeCore`; the public `react-native/setup-env` entry point and its deprecation of InitializeCore are unchanged. The proper fix (make `setup-env` graph-reachable, or make Metro treat `getModulesRunBeforeMainModule` entries as graph roots) should land on main and supersede this. Changelog: [General][Fixed] - Fix apps failing to boot ("RCTDeviceEventEmitter not registered as callable") due to core init not running. Test Plan: - `yarn test-release-local -t RNTestProject -p iOS`: app boots without redbox. - Bundle tail now contains `__r(<InitializeCore>); __r(0);` instead of just `__r(0);`.
Member
|
(Resolved by reactwg/react-native-releases#1338. #57498 is non-cosmetic — but also this happened to due a race condition/selective picking with #57484.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fresh 0.87 projects redbox on launch:
Only
AppRegistryis registered as callable — i.e. core initialization never runs.Root cause (#57475)
Core init runs via Metro's
serializer.getModulesRunBeforeMainModule. Metro (metro/src/lib/getAppendScripts.js) only emits the run-before__r()for a module already present in the bundle graph, and silently skips it otherwise:#57475 switched the run-before target from
Libraries/Core/InitializeCore→src/setup-env.js.InitializeCore.jsis reachable (imported byLibraries/ReactPrivate/ReactNativePrivateInitializeCore.js).src/setup-env.jsis imported by nothing → not in the graph → silently skipped → core init never runs.The two modules are functionally identical (both call
setUpDefaultReactNativeEnvironment().default()), so only reachability changed.Evidence (bundle tail)
src/setup-env.js(current)__r(0);Libraries/Core/InitializeCore(this PR)__r(110); __r(0);Ruled out: Metro cache (cold
--reset-cacheidentical), stale Metro, and #57484 (./src/*exports removal — restoring it did not help).Scope — interim stopgap
This only reverts the internal Metro bootstrap target back to
InitializeCore. It does not touch the publicreact-native/setup-enventry point or its deprecation ofInitializeCore— those ship unchanged.The proper fix (make
setup-envgraph-reachable, or make Metro treatgetModulesRunBeforeMainModuleentries as graph roots) should land onmainand supersede this. cc @huntie — this is yoursetup-envstack; flagging for the durable fix. Notemainuses equivalent wiring (its follow-up #57498 is cosmetic — resolves to the same unreachable file), somainis likely affected too.Changelog
[General][Fixed] - Fix apps failing to boot ("RCTDeviceEventEmitter not registered as callable") caused by core init not running.
Test Plan
yarn test-release-local -t RNTestProject -p iOS: app boots without the redbox.__r(<InitializeCore>); __r(0);instead of just__r(0);.