From c2c2e6b7c23e60845281f29723d70d9bb20ee599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Tue, 12 Aug 2025 05:41:11 -0700 Subject: [PATCH] Connect debugger before loading bundle (#53203) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53203 Changelog: [internal] This makes ReactHost connect the inspector immediately after creating the instance, aligned with how we do it on Android, instead of doing it as part of loading a bundle. Reviewed By: rshest Differential Revision: D79804004 fbshipit-source-id: b165520b0feb089fdfaa323413d697939c7ac794 --- .../ReactCxxPlatform/react/runtime/ReactHost.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactCxxPlatform/react/runtime/ReactHost.cpp b/packages/react-native/ReactCxxPlatform/react/runtime/ReactHost.cpp index bcd8d15f8ae..b53b2b83bcf 100644 --- a/packages/react-native/ReactCxxPlatform/react/runtime/ReactHost.cpp +++ b/packages/react-native/ReactCxxPlatform/react/runtime/ReactHost.cpp @@ -240,6 +240,10 @@ void ReactHost::createReactInstance() { auto jsInvoker = std::make_shared( reactInstance_->getRuntimeScheduler()); + if (inspector_ != nullptr) { + inspector_->connectDebugger(devServerHelper_->getInspectorUrl()); + } + auto liveReloadCallback = [this]() { reloadReactInstance(); }; reactInstance_->initializeRuntime( { @@ -451,9 +455,6 @@ bool ReactHost::loadScriptFromDevServer() { auto script = std::make_unique(response); reactInstance_->loadScript( std::move(script), devServerHelper_->getBundleUrl()); - if (inspector_ != nullptr) { - inspector_->connectDebugger(devServerHelper_->getInspectorUrl()); - } devServerHelper_->setupHMRClient(); return true; } catch (...) {