Skip to content

Commit b71a6b6

Browse files
committed
Work around existing bugs
1 parent 468a289 commit b71a6b6

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
@@ -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`.

0 commit comments

Comments
 (0)