File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
packages/next/src/client/components/router-reducer Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,19 @@ export async function fetchServerResponse(
165165 isNavigation &&
166166 ! process . env . TURBOPACK
167167 ) {
168- await waitForWebpackRuntimeHotUpdate ( )
168+ const webpackHMRTimedOut = await Promise . race ( [
169+ waitForWebpackRuntimeHotUpdate ( ) . then ( ( ) => false ) ,
170+ new Promise ( ( resolve ) => setTimeout ( ( ) => resolve ( true ) , 2000 ) ) ,
171+ ] )
172+
173+ // Work around existing bugs where we receive an HRM update but no message that it was finished.
174+ // Having the log before an MPA is pretty bad since it'll just flash the page and then navigate.
175+ if ( webpackHMRTimedOut ) {
176+ console . error (
177+ 'Webpack runtime hot update timed out. Falling back to browser navigation.'
178+ )
179+ return doMpaNavigation ( responseUrl . toString ( ) )
180+ }
169181 }
170182
171183 // Handle the `fetch` readable stream that can be unwrapped by `React.use`.
You can’t perform that action at this time.
0 commit comments