Skip to content

Commit db98db4

Browse files
committed
Work around existing bugs
1 parent 615ff09 commit db98db4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/next/src/client/components/router-reducer/fetch-server-response.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,19 @@ export async function fetchServerResponse(
193193
isNavigation &&
194194
!process.env.TURBOPACK
195195
) {
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+
}
197209
}
198210

199211
// Handle the `fetch` readable stream that can be unwrapped by `React.use`.

0 commit comments

Comments
 (0)