@samitouri / QOS-React / commits / 7023f501b6

[DevTools] Don't reconnect proxy port while page is prerendering (#37009)

Saransh Jain committed Jul 14, 2026 at 14:34 UTC 7023f501b644815e29a621875c0379ea757905f6
1 file changed +12 -1
packages/react-devtools-extensions/src/contentScripts/proxy.js
+12 -1
@@ -114,7 +114,18 @@ function handleDisconnect() {
114 window.removeEventListener('message', handleMessageFromPage);
115 port = null;
116
117 - connectPort();
117 + // Mirrors the guard in handlePageShow(): the background script can evict/
118 + // replace a tab's proxy port (see registerProxyPort in background/index.js),
119 + // which disconnects us while still prerendering. Reconnecting immediately
120 + // in that case causes an unbounded connect/disconnect cycle for as long as
121 + // the document stays in the prerendering state (https://crbug.com/478909972).
122 + if (document.prerendering) {
123 + document.addEventListener('prerenderingchange', connectPort, {
124 + once: true,
125 + });
126 + } else {
127 + connectPort();
128 + }
129 }
130
131 // Creates port from application page to the React DevTools' service worker