mirror of
https://github.com/facebook/react-native.git
synced 2024-11-21 22:10:14 +00:00
earlyjs: Extend C++ pipeline for non-js errors (#47529)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47529 RuntimeExecutor, RuntimeScheduler, etc. can execute arbitrary c++ on the javascript thread. If that c++ throws a non-jsi::JSError, it will bypass the js error handler (and start tearing down the react instance 😱). Let's have the js error handler manage all exceptions raised while native is calling into js. This is more sane. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D64626610 fbshipit-source-id: 40132f24b4e2737ae3f055fbd09153111404e5bf
This commit is contained in:
parent
998ab262ea
commit
ca7b9e9509
@ -170,6 +170,9 @@ void RuntimeScheduler_Legacy::callExpiredTasks(jsi::Runtime& runtime) {
|
||||
}
|
||||
} catch (jsi::JSError& error) {
|
||||
onTaskError_(runtime, error);
|
||||
} catch (std::exception& ex) {
|
||||
jsi::JSError error(runtime, std::string("Non-js exception: ") + ex.what());
|
||||
onTaskError_(runtime, error);
|
||||
}
|
||||
|
||||
currentPriority_ = previousPriority;
|
||||
@ -233,6 +236,9 @@ void RuntimeScheduler_Legacy::startWorkLoop(jsi::Runtime& runtime) {
|
||||
}
|
||||
} catch (jsi::JSError& error) {
|
||||
onTaskError_(runtime, error);
|
||||
} catch (std::exception& ex) {
|
||||
jsi::JSError error(runtime, std::string("Non-js exception: ") + ex.what());
|
||||
onTaskError_(runtime, error);
|
||||
}
|
||||
|
||||
currentPriority_ = previousPriority;
|
||||
|
@ -386,6 +386,9 @@ void RuntimeScheduler_Modern::executeTask(
|
||||
}
|
||||
} catch (jsi::JSError& error) {
|
||||
onTaskError_(runtime, error);
|
||||
} catch (std::exception& ex) {
|
||||
jsi::JSError error(runtime, std::string("Non-js exception: ") + ex.what());
|
||||
onTaskError_(runtime, error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -420,6 +423,10 @@ void RuntimeScheduler_Modern::performMicrotaskCheckpoint(
|
||||
}
|
||||
} catch (jsi::JSError& error) {
|
||||
onTaskError_(runtime, error);
|
||||
} catch (std::exception& ex) {
|
||||
jsi::JSError error(
|
||||
runtime, std::string("Non-js exception: ") + ex.what());
|
||||
onTaskError_(runtime, error);
|
||||
}
|
||||
retries++;
|
||||
}
|
||||
|
@ -103,6 +103,10 @@ ReactInstance::ReactInstance(
|
||||
}
|
||||
} catch (jsi::JSError& originalError) {
|
||||
jsErrorHandler->handleError(jsiRuntime, originalError, true);
|
||||
} catch (std::exception& ex) {
|
||||
jsi::JSError error(
|
||||
jsiRuntime, std::string("Non-js exception: ") + ex.what());
|
||||
jsErrorHandler->handleError(jsiRuntime, error, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user