diff --git a/packages/react-native/ReactCommon/jsinspector-modern/HostAgent.cpp b/packages/react-native/ReactCommon/jsinspector-modern/HostAgent.cpp index 9464d625695..813770d51ad 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/HostAgent.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/HostAgent.cpp @@ -146,6 +146,19 @@ class HostAgent::Impl final { } if (InspectorFlags::getInstance().getNetworkInspectionEnabled()) { if (req.method == "Network.enable") { + auto& inspector = getInspectorInstance(); + if (inspector.getSystemState().registeredPagesCount > 1) { + frontendChannel_( + cdp::jsonError( + req.id, + cdp::ErrorCode::InternalError, + "The Network domain is unavailable when multiple React Native hosts are registered.")); + return { + .isFinishedHandlingRequest = true, + .shouldSendOKResponse = false, + }; + } + sessionState_.isNetworkDomainEnabled = true; return { @@ -386,9 +399,7 @@ class HostAgent::Impl final { "ReactNativeApplication.systemStateChanged", folly::dynamic::object("isSingleHost", isSingleHost))); - if (!isSingleHost) { - frontendChannel_(cdp::jsonNotification("Network.disable")); - } + frontendChannel_(cdp::jsonNotification("Network.disable")); } private: diff --git a/packages/react-native/ReactCommon/jsinspector-modern/TracingAgent.cpp b/packages/react-native/ReactCommon/jsinspector-modern/TracingAgent.cpp index e661b0e741a..823c56ecfaa 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/TracingAgent.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/TracingAgent.cpp @@ -53,7 +53,17 @@ TracingAgent::~TracingAgent() { bool TracingAgent::handleRequest(const cdp::PreparsedRequest& req) { if (req.method == "Tracing.start") { - // @cdp Tracing.start support is experimental. + auto& inspector = getInspectorInstance(); + if (inspector.getSystemState().registeredPagesCount > 1) { + frontendChannel_( + cdp::jsonError( + req.id, + cdp::ErrorCode::InternalError, + "The Tracing domain is unavailable when multiple React Native hosts are registered.")); + + return true; + } + if (sessionState_.isDebuggerDomainEnabled) { frontendChannel_( cdp::jsonError(