[DevTools] Don't reconnect proxy port while page is prerendering (#37β¦
[DevTools] Don't reconnect proxy port while page is prerendering (#37009)
File tree
Expand file tree Collapse file tree
packages/react-devtools-extensions/src/contentScripts
Expand file tree Collapse file tree
| Original file line number | Diff line number | Diff line change |
|---|
@@ -114,7 +114,18 @@ function handleDisconnect() {
114 | 114 | window . removeEventListener ( 'message' , handleMessageFromPage ) ;
115 | 115 | port = null ;
116 | 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 | + }
118 | 129 | }
119 | 130 |
120 | 131 | // Creates port from application page to the React DevTools' service worker
You canβt perform that action at this time.
0 commit comments
Comments
No comments yet. Start the discussion.