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 @@ -165,7 +165,19 @@ export async function fetchServerResponse(
165
165
isNavigation &&
166
166
! process . env . TURBOPACK
167
167
) {
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
+ }
169
181
}
170
182
171
183
// Handle the `fetch` readable stream that can be unwrapped by `React.use`.
You can’t perform that action at this time.
0 commit comments