Skip to content

Commit

Permalink
Work around existing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jul 18, 2024
1 parent dc89766 commit 7f91406
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,19 @@ export async function fetchServerResponse(
isNavigation &&
!process.env.TURBOPACK
) {
await waitForWebpackRuntimeHotUpdate()
const webpackHMRTimedOut = await Promise.race([
waitForWebpackRuntimeHotUpdate().then(() => false),
new Promise((resolve) => setTimeout(() => resolve(true), 2000)),
])

// Work around existing bugs where we receive an HRM update but no message that it was finished.
// Having the log before an MPA is pretty bad since it'll just flash the page and then navigate.
if (webpackHMRTimedOut) {
console.error(
'Webpack runtime hot update timed out. Falling back to browser navigation.'
)
return doMpaNavigation(responseUrl.toString())
}
}

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

0 comments on commit 7f91406

Please sign in to comment.