Skip to content

Commit

Permalink
fix[dynamic-scripts-injection]: unregister content scripts before reg…
Browse files Browse the repository at this point in the history
…istration (#26765)

## Summary
Fixes #26756.

DevTools is failing to inject `__REACT_DEVTOOLS_GLOBAL_HOOK__` hook in
incognito mode. This is not happening straight-forward, but if extension
is toggled on and off, the next time I try to open it I am receiving an
error that content script was already registered.

<img width="676" alt="Screenshot 2023-05-02 at 14 36 53"
src="https://user-images.githubusercontent.com/28902667/235877692-51c5d284-79d9-4b00-b62e-d25d5bb5e056.png">

- Unregistering content scripts before attempting to register them
again. We need to inject `__REACT_DEVTOOLS_GLOBAL_HOOK__` on each page,
so this should be expected behaviour.
- Fixed error logging

## How did you test this change?
Local build of extension for Chrome, trying the same steps, which
resulted in an error.
No regression in performance, tested on react.dev, still the same.

DiffTrain build for commit 8a25302.
  • Loading branch information
hoxyq committed May 3, 2023
1 parent ba4ef65 commit 13a4471
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23918,7 +23918,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-canary-2c2476834-20230503";
var ReactVersion = "18.3.0-canary-8a25302c6-20230503";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8623,7 +8623,7 @@ var devToolsConfig$jscomp$inline_1039 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-2c2476834-20230503",
version: "18.3.0-canary-8a25302c6-20230503",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1238 = {
Expand Down Expand Up @@ -8654,7 +8654,7 @@ var internals$jscomp$inline_1238 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-2c2476834-20230503"
reconcilerVersion: "18.3.0-canary-8a25302c6-20230503"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1239 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9049,7 +9049,7 @@ var devToolsConfig$jscomp$inline_1081 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-2c2476834-20230503",
version: "18.3.0-canary-8a25302c6-20230503",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1279 = {
Expand Down Expand Up @@ -9080,7 +9080,7 @@ var internals$jscomp$inline_1279 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-2c2476834-20230503"
reconcilerVersion: "18.3.0-canary-8a25302c6-20230503"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1280 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-canary-2c2476834-20230503";
var ReactVersion = "18.3.0-canary-8a25302c6-20230503";

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,4 +645,4 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-canary-2c2476834-20230503";
exports.version = "18.3.0-canary-8a25302c6-20230503";
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-canary-2c2476834-20230503";
exports.version = "18.3.0-canary-8a25302c6-20230503";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2c2476834a7c739ca239750b73f74aa1df144a93
8a25302c668d6f9a24f6680fb4947e9b388bb7d9

0 comments on commit 13a4471

Please sign in to comment.