Commit df86c5e
Fix iOS Metro reload after initial bundle failure (#58352)
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. `RCTInstance` resolves the `DevSettings` TurboModule only inside `_loadJSBundle`'s success callback, and `RCTDevSettings.initialize` is what registers the Metro `reload` message handler. No successful first load means no handler, so the app never becomes a Metro reload peer.
This resolves `DevSettings` at 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.
Pull Request resolved: #58352
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 PID `95823` unchanged. 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 `14848` unchanged.
Reviewed By: christophpurrer
Differential Revision: D119072108
Pulled By: javache
fbshipit-source-id: 8774564b990417cc143f55ba935b809f50eff4851 parent 73a76dd commit df86c5e
1 file changed
Lines changed: 4 additions & 1 deletion
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
537 | 537 | | |
538 | 538 | | |
539 | 539 | | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
540 | 544 | | |
541 | 545 | | |
542 | 546 | | |
| |||
569 | 573 | | |
570 | 574 | | |
571 | 575 | | |
572 | | - | |
573 | 576 | | |
574 | 577 | | |
575 | 578 | | |
| |||
0 commit comments