Fix disappearing redbox on initial load of an invalid bundle. #50867
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:
Right now having a javascript error like an invalid import statement during first bundle load results in a disappearing redbox screen.
Untitled.mp4
The
invalidate
call removed in this PR cleans up all turbomodules, including the RedBox module, which in turns callsdismiss
inRCTRedBox
.After removing this line the result is as following:
Simulator.Screen.Recording.-.iPhone.16.Pro.Max.-.2025-04-23.at.13.14.16.mp4
I made sure that the
invalidate
function is still called when executing only two possible ways to reload the bundle:The HMR/hot reload is not connected if the bundle has an error on initial load, so we don't need to worry about it.
Longer term, it would be better to establish HMR and use a different redbox in this case:
Doing this requires larger changes to the bundle loading flow – happy to to try and land that change if there's any guidance you could give.
Changelog:
[IOS][FIXED] – Fix disappearing redbox on initial load of an invalid bundle.
Test Plan:
I have tested this change using RN from main and RNTester app (see videos).