Skip to content

Commit 2f8d4f0

Browse files
RSNarafacebook-github-bot
authored andcommitted
Ensure redbox shows up after reloads fail (#44959)
Summary: Pull Request resolved: #44959 If a react instance create fails, ReactHost [calls handleHostException](https://www.internalfb.com/code/fbsource/[bf94dae8c8b7527653145fdd799f6f47b1f8b284]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java?lines=784-793%2C956-959%2C966%2C979-980%2C982%2C985-986). This method uses the dev support manager to show the redbox: line 789. https://www.internalfb.com/code/fbsource/[bf94dae8c8b7527653145fdd799f6f47b1f8b284]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java?lines=784-793 But, if react instance reload fails, react host does everything in handleHostException, **except** call into dev support manager to show the redbox. https://www.internalfb.com/code/fbsource/[bf94dae8c8b7527653145fdd799f6f47b1f8b284]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java?lines=457-466 Hence, the redbox doesn't show. ## Thoughts These two code-paths do really similar things. I'm thinking about how to unify them. Changelog: [Android][Fixed] Show RedBox after reloads fail (bridgeless) Reviewed By: alanleedev Differential Revision: D58592928 fbshipit-source-id: 37a7adc1845a8b28917fcd9acbaae1484478e4e6
1 parent ce2e426 commit 2f8d4f0

File tree

1 file changed

+6
-2
lines changed
  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime

1 file changed

+6
-2
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,12 @@ public TaskInterface<Void> reload(String reason) {
457457
return reloadTask.continueWithTask(
458458
task -> {
459459
if (task.isFaulted()) {
460-
mReactHostDelegate.handleInstanceException(task.getError());
461-
return getOrCreateDestroyTask("Reload failed", task.getError());
460+
final Exception ex = task.getError();
461+
if (mUseDevSupport) {
462+
mDevSupportManager.handleException(ex);
463+
}
464+
mReactHostDelegate.handleInstanceException(ex);
465+
return getOrCreateDestroyTask("Reload failed", ex);
462466
}
463467

464468
return task;

0 commit comments

Comments
 (0)