diff --git a/packages/renderer/src/fiber-hook.ts b/packages/renderer/src/fiber-hook.ts index 5b0e77f..af35838 100644 --- a/packages/renderer/src/fiber-hook.ts +++ b/packages/renderer/src/fiber-hook.ts @@ -179,58 +179,92 @@ export function buildProxyFiberHookScript(): string { } // ── React DevTools global hook ──────────────────────────────────────────── - // Strategy: completely replace window.__REACT_DEVTOOLS_GLOBAL_HOOK__ with a - // fresh, fully-specified hook object. This eliminates all timing hazards: + // Two-layer bulletproof strategy: // - // 1. Chrome DevTools extension injects at document_start (before HTML is - // parsed) and installs a stub where hook.inject = undefined. Patching - // that stub still leaves React Refresh free to capture undefined before - // our patch runs. Replacing the object entirely avoids the problem. + // LAYER 1 — Lock the global: replace window.__REACT_DEVTOOLS_GLOBAL_HOOK__ + // with our fresh hook, then make the property non-writable so neither the + // Chrome DevTools extension (which runs at document_start and may + // re-initialize) nor any webpack module can swap it out again. // - // 2. React Refresh (Next.js dev) runs after our