Skip to content

Commit d82b6a4

Browse files
committed
fix: try catch setting __REACT_DEVTOOLS_GLOBAL_HOOK__ incase old bippy version blocked the write
1 parent 526de16 commit d82b6a4

File tree

2 files changed

+24
-1821
lines changed

2 files changed

+24
-1821
lines changed

packages/bippy/src/rdt-hook.ts

+18-9
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,25 @@ export const installRDTHook = (
9696
let hasRanHack = false;
9797
objectDefineProperty(window, 'hasOwnProperty', {
9898
value: function (this: unknown) {
99-
// biome-ignore lint/style/noArguments: perf
100-
if (!hasRanHack && arguments[0] === '__REACT_DEVTOOLS_GLOBAL_HOOK__') {
101-
globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__ = undefined;
102-
// special falsy value to know that we've already installed before
103-
hasRanHack = true;
104-
return -0;
99+
try {
100+
if (
101+
!hasRanHack &&
102+
// biome-ignore lint/style/noArguments: perf
103+
arguments[0] === '__REACT_DEVTOOLS_GLOBAL_HOOK__'
104+
) {
105+
globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__ = undefined;
106+
// special falsy value to know that we've already installed before
107+
hasRanHack = true;
108+
return -0;
109+
}
110+
// biome-ignore lint/suspicious/noExplicitAny: perf
111+
// biome-ignore lint/style/noArguments: perf
112+
return originalWindowHasOwnProperty.apply(this, arguments as any);
113+
} catch {
114+
// biome-ignore lint/suspicious/noExplicitAny: perf
115+
// biome-ignore lint/style/noArguments: perf
116+
return originalWindowHasOwnProperty.apply(this, arguments as any);
105117
}
106-
// biome-ignore lint/suspicious/noExplicitAny: perf
107-
// biome-ignore lint/style/noArguments: perf
108-
return originalWindowHasOwnProperty.apply(this, arguments as any);
109118
},
110119
configurable: true,
111120
writable: true,

0 commit comments

Comments
 (0)