mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Destroy React Native instance after catching a fatal js error
Summary: As title, destroy React Native instance after catching a fatal js error to avoid incoming calls into JS. Changelog: [Android][Changed] - Rename NativeModuleCallExceptionHandler to JSExceptionHandler for broader usage Reviewed By: fkgozali Differential Revision: D37379340 fbshipit-source-id: 465a30bc824a264b45df3e8b0b24edd61c4b571d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ca8481bd7d
commit
b6f7689d70
+2
-2
@@ -218,8 +218,8 @@ public class ReactAppTestActivity extends FragmentActivity
|
||||
builder.setReactPackageTurboModuleManagerDelegateBuilder(
|
||||
spec.getReactPackageTurboModuleManagerDelegateBuilder());
|
||||
}
|
||||
if (spec.getNativeModuleCallExceptionHandler() != null) {
|
||||
builder.setNativeModuleCallExceptionHandler(spec.getNativeModuleCallExceptionHandler());
|
||||
if (spec.getJSExceptionHandler() != null) {
|
||||
builder.setJSExceptionHandler(spec.getJSExceptionHandler());
|
||||
}
|
||||
|
||||
if (!spec.getAlternativeReactPackagesForTest().isEmpty()) {
|
||||
|
||||
+6
-7
@@ -11,11 +11,11 @@ import android.annotation.SuppressLint;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
|
||||
import com.facebook.react.bridge.JSExceptionHandler;
|
||||
import com.facebook.react.bridge.JSIModuleSpec;
|
||||
import com.facebook.react.bridge.JavaScriptExecutorFactory;
|
||||
import com.facebook.react.bridge.JavaScriptModule;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import java.util.ArrayList;
|
||||
@@ -40,7 +40,7 @@ public class ReactInstanceSpecForTest {
|
||||
private final List<Class<? extends JavaScriptModule>> mJSModuleSpecs = new ArrayList<>();
|
||||
private final List<ViewManager> mViewManagers = new ArrayList<>();
|
||||
private final ArrayList<ReactPackage> mReactPackages = new ArrayList<>();
|
||||
@Nullable private NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler = null;
|
||||
@Nullable private JSExceptionHandler mJSExceptionHandler = null;
|
||||
@Nullable private FabricUIManagerFactory mFabricUIManagerFactory = null;
|
||||
@Nullable private JavaScriptExecutorFactory mJavaScriptExecutorFactory = null;
|
||||
@Nullable private ReactPackageTurboModuleManagerDelegate.Builder mTMMDelegateBuilder = null;
|
||||
@@ -51,14 +51,13 @@ public class ReactInstanceSpecForTest {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReactInstanceSpecForTest setNativeModuleCallExceptionHandler(
|
||||
NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
|
||||
mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
|
||||
public ReactInstanceSpecForTest setJSExceptionHandler(JSExceptionHandler jSExceptionHandler) {
|
||||
mJSExceptionHandler = jSExceptionHandler;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NativeModuleCallExceptionHandler getNativeModuleCallExceptionHandler() {
|
||||
return mNativeModuleCallExceptionHandler;
|
||||
public JSExceptionHandler getJSExceptionHandler() {
|
||||
return mJSExceptionHandler;
|
||||
}
|
||||
|
||||
public ReactInstanceSpecForTest setJavaScriptExecutorFactory(
|
||||
|
||||
@@ -24,9 +24,9 @@ import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.bridge.CatalystInstance;
|
||||
import com.facebook.react.bridge.CatalystInstanceImpl;
|
||||
import com.facebook.react.bridge.JSBundleLoader;
|
||||
import com.facebook.react.bridge.JSExceptionHandler;
|
||||
import com.facebook.react.bridge.JavaScriptExecutor;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.NativeModuleCallExceptionHandler;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
|
||||
import com.facebook.react.modules.core.ReactChoreographer;
|
||||
@@ -90,8 +90,8 @@ public class ReactTestHelper {
|
||||
.setJSBundleLoader(
|
||||
JSBundleLoader.createAssetLoader(
|
||||
mContext, "assets://AndroidTestBundle.js", false /* Asynchronous */))
|
||||
.setNativeModuleCallExceptionHandler(
|
||||
new NativeModuleCallExceptionHandler() {
|
||||
.setJSExceptionHandler(
|
||||
new JSExceptionHandler() {
|
||||
@Override
|
||||
public void handleException(Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
Reference in New Issue
Block a user