From 8c26048df689c478b8564ab47be164dcc75fb0da Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Wed, 14 Aug 2024 20:43:11 -0700 Subject: [PATCH] ReactInstance: Remove redundant try/catch in loadScript (#45617) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45617 This isn't necessary. RuntimeScheduler will catch and report via js error handler. Changelog: [Internal] Reviewed By: alanleedev Differential Revision: D60139055 fbshipit-source-id: 511f384ede71d88b81ef5c031fa67b1fb03f7631 --- .../react/runtime/ReactInstance.cpp | 55 +++++++++---------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp index 075023b63fc..e4cee80023f 100644 --- a/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp +++ b/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp @@ -215,37 +215,34 @@ void ReactInstance::loadScript( buffer = std::move(buffer), weakBufferedRuntimeExecuter = std::weak_ptr( bufferedRuntimeExecutor_)](jsi::Runtime& runtime) { - try { - SystraceSection s("ReactInstance::loadScript"); - bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl); - if (hasLogger) { - ReactMarker::logTaggedMarkerBridgeless( - ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str()); - } + SystraceSection s("ReactInstance::loadScript"); + bool hasLogger(ReactMarker::logTaggedMarkerBridgelessImpl); + if (hasLogger) { + ReactMarker::logTaggedMarkerBridgeless( + ReactMarker::RUN_JS_BUNDLE_START, scriptName.c_str()); + } - runtime.evaluateJavaScript(buffer, sourceURL); + runtime.evaluateJavaScript(buffer, sourceURL); - /** - * TODO(T183610671): We need a safe/reliable way to enable the js - * pipeline from javascript. Remove this after we figure that out, or - * after we just remove the js pipeline. - */ - if (!jsErrorHandler_->hasHandledFatalError()) { - jsErrorHandler_->setRuntimeReady(); - } - if (hasLogger) { - ReactMarker::logTaggedMarkerBridgeless( - ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str()); - ReactMarker::logMarkerBridgeless( - ReactMarker::INIT_REACT_RUNTIME_STOP); - ReactMarker::logMarkerBridgeless(ReactMarker::APP_STARTUP_STOP); - } - if (auto strongBufferedRuntimeExecuter = - weakBufferedRuntimeExecuter.lock()) { - strongBufferedRuntimeExecuter->flush(); - } - } catch (jsi::JSError& error) { - jsErrorHandler_->handleFatalError(runtime, error); + /** + * TODO(T183610671): We need a safe/reliable way to enable the js + * pipeline from javascript. Remove this after we figure that out, or + * after we just remove the js pipeline. + */ + if (!jsErrorHandler_->hasHandledFatalError()) { + jsErrorHandler_->setRuntimeReady(); + } + + if (hasLogger) { + ReactMarker::logTaggedMarkerBridgeless( + ReactMarker::RUN_JS_BUNDLE_STOP, scriptName.c_str()); + ReactMarker::logMarkerBridgeless( + ReactMarker::INIT_REACT_RUNTIME_STOP); + ReactMarker::logMarkerBridgeless(ReactMarker::APP_STARTUP_STOP); + } + if (auto strongBufferedRuntimeExecuter = + weakBufferedRuntimeExecuter.lock()) { + strongBufferedRuntimeExecuter->flush(); } }); }