File tree 1 file changed +13
-1
lines changed
packages/next/src/client/components/router-reducer
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,19 @@ export async function fetchServerResponse(
193
193
isNavigation &&
194
194
! process . env . TURBOPACK
195
195
) {
196
- await waitForWebpackRuntimeHotUpdate ( )
196
+ const webpackHMRTimedOut = await Promise . race ( [
197
+ waitForWebpackRuntimeHotUpdate ( ) . then ( ( ) => false ) ,
198
+ new Promise ( ( resolve ) => setTimeout ( ( ) => resolve ( true ) , 2000 ) ) ,
199
+ ] )
200
+
201
+ // Work around existing bugs where we receive an HRM update but no message that it was finished.
202
+ // Having the log before an MPA is pretty bad since it'll just flash the page and then navigate.
203
+ if ( webpackHMRTimedOut ) {
204
+ console . error (
205
+ 'Webpack runtime hot update timed out. Falling back to browser navigation.'
206
+ )
207
+ return doMpaNavigation ( responseUrl . toString ( ) )
208
+ }
197
209
}
198
210
199
211
// Handle the `fetch` readable stream that can be unwrapped by `React.use`.
You can’t perform that action at this time.
0 commit comments