Skip to content

Commit 5ca6a69

Browse files
authoredMay 7, 2020
fix: catch throwable instead of exception in restartmodule.java (#133)
This updates the try/catch blocks in RestartModule.java to catch Throwable instead of Exception to fall back to loading the legacy bundle. recreateReactContextInBackground in React Native throws an AssertionError (which is an instance of Error, not Exception), meaning that the error wasn't being caught and our app was crashing. See https://github.com/facebook/react-native/blob/65d52a59b044b2e8f7712af5542c4649689363fa/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java#L390
1 parent 523494d commit 5ca6a69

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎android/src/main/java/com/reactnativerestart/RestartModule.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ private void loadBundle() {
4848
public void run() {
4949
try {
5050
instanceManager.recreateReactContextInBackground();
51-
} catch (Exception e) {
51+
} catch (Throwable t) {
5252
loadBundleLegacy();
5353
}
5454
}
5555
});
5656

57-
} catch (Exception e) {
57+
} catch (Throwable t) {
5858
loadBundleLegacy();
5959
}
6060
}

0 commit comments

Comments
 (0)
Please sign in to comment.