Fix iOS Metro reload after initial bundle failure - #58352
Open
janicduplessis wants to merge 6 commits into
Open
Conversation
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:
In bridgeless iOS apps,
RCTInstancecurrently resolvesDevSettingsonly after the initial bundle has loaded successfully.RCTDevSettings.initializeowns the Metroreloadmessage handler, so an app whose first bundle request fails remains alive but cannot receive the same Metro reload command that Android handles natively.Resolve
DevSettingsfrom the existing bundle-error handler after its instance-validity check. This preserves the successful-load timing and HMR setup, establishes the Metro command connection on the initial bundle-error path, and avoids initializing a stale connection when an in-flight request completes after invalidation. The module is not retained across the asynchronous request.The lifecycle tests assert that
DevSettingsremains uninitialized while the request is pending, initializes when the initial bundle request fails, and stays uninitialized when that request completes after invalidation.Changelog:
[IOS] [FIXED] - Allow Metro reload after an initial bundle-load failure.
Test Plan:
RCTInstanceTests.testInitializesDevSettingsAfterBundleLoadFailureandRCTInstanceTests.testDoesNotInitializeDevSettingsAfterInvalidationXCTest cases on an iOS 26.5 simulator: 2 tests, 0 failures.DevSettingsinitialization.{version: 2, method: "reload"}to Metro; RNTester requested a corrected bundle and recovered with native PID95823unchanged. A consecutive Metro reload also completed with PID95823unchanged.14848unchanged.Android expected-behavior comparison:
rntester-android-reload-full.mp4