Fix iOS Metro reload after initial bundle failure - #58352
Open
janicduplessis wants to merge 7 commits into
Open
Conversation
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D119072108. |
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:
If the first bundle request fails on bridgeless iOS, Metro reload does nothing — the app sits on the error screen and has to be killed and relaunched, even once the source is fixed. Android already handles this.
The cause is timing.
RCTInstanceresolves theDevSettingsTurboModule only inside_loadJSBundle's success callback, andRCTDevSettings.initializeis what registers the Metroreloadmessage handler. No successful first load means no handler, so the app never becomes a Metro reload peer.This resolves
DevSettingsat the top of_loadJSBundle, before the request is issued, so the handler is registered regardless of how that request turns out. The callback keeps its own resolution for the HMR setup that follows it.Changelog:
[IOS] [FIXED] - Allow Metro reload after an initial bundle-load failure.
Test Plan:
On RNTester (iOS 26.5 simulator), launched with an unresolved import so the initial bundle fails, then restored the source and waited 10 seconds: the error stayed and Metro received no bundle request, confirming the app was not a reload peer. Sending
{version: 2, method: "reload"}to Metro then made it request a corrected bundle and recover in place, native PID95823unchanged. A second consecutive reload also worked.Same scenario on Android RNTester as the reference: it already receives the Metro command on the initial-error path, recovering with PID
14848unchanged.