mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Update Network and Tracing handlers to error under multiple hosts (#54408)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54408 Follows from the parent commit. This will prevent 3P CDP clients from using the `Tracing` or `Network` domains when we are in an unsupported multi React Native Host setup. Changelog: [Internal] Reviewed By: hoxyq Differential Revision: D86201688 fbshipit-source-id: 052d563a371fd77c1a05ad8518e222d6bc1eb372
This commit is contained in:
1 parent
74d687c213
commit
6fd2cc27f8
2 files changed
+25
-4
No files matched your search
@@ -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:
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user