Skip to content

Commit

Permalink
Turbopack + pages router: recover from runtime errors be reloading
Browse files Browse the repository at this point in the history
An iteration of #62359, this uses the module-local flag instead of a shared dedicated module for flagging runtime errors, correctly reloading the page when these occur.

Test Plan: See now-passing tests in the manifest.
  • Loading branch information
wbinnssmith committed Mar 8, 2024
1 parent c206d89 commit e9104e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/next/src/client/dev/error-overlay/hot-dev-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import type {
TurbopackMsgToBrowser,
} from '../../../server/dev/hot-reloader-types'
import { extractModulesFromTurbopackMessage } from '../../../server/dev/extract-modules-from-turbopack-message'
import { RuntimeErrorHandler } from '../../components/react-dev-overlay/internal/helpers/runtime-error-handler'
import { REACT_REFRESH_FULL_RELOAD_FROM_ERROR } from './messages'
// This alternative WebpackDevServer combines the functionality of:
// https://github.com/webpack/webpack-dev-server/blob/webpack-1/client/index.js
Expand Down Expand Up @@ -346,7 +345,7 @@ function processMessage(obj: HMR_ACTION_TYPES) {
data: obj.data,
})
}
if (RuntimeErrorHandler.hadRuntimeError) {
if (hadRuntimeError) {
console.warn(REACT_REFRESH_FULL_RELOAD_FROM_ERROR)
performFullReload(null)
}
Expand Down
4 changes: 2 additions & 2 deletions test/turbopack-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,7 @@
"basic HMR, basePath: \"\" Error Recovery should recover after undefined exported as default",
"basic HMR, basePath: \"\" Error Recovery should recover from 404 after a page has been added",
"basic HMR, basePath: \"\" Error Recovery should recover from 404 after a page has been added with dynamic segments",
"basic HMR, basePath: \"\" Error Recovery should recover from errors in getInitialProps in client",
"basic HMR, basePath: \"\" Hot Module Reloading delete a page and add it back should load the page properly",
"basic HMR, basePath: \"\" Hot Module Reloading editing a page should detect the changes and display it",
"basic HMR, basePath: \"\" Hot Module Reloading editing a page should not reload unrelated pages",
Expand All @@ -1566,6 +1567,7 @@
"basic HMR, basePath: \"/docs\" Error Recovery should recover after undefined exported as default",
"basic HMR, basePath: \"/docs\" Error Recovery should recover from 404 after a page has been added",
"basic HMR, basePath: \"/docs\" Error Recovery should recover from 404 after a page has been added with dynamic segments",
"basic HMR, basePath: \"/docs\" Error Recovery should recover from errors in getInitialProps in client",
"basic HMR, basePath: \"/docs\" Hot Module Reloading delete a page and add it back should load the page properly",
"basic HMR, basePath: \"/docs\" Hot Module Reloading editing a page should detect the changes and display it",
"basic HMR, basePath: \"/docs\" Hot Module Reloading editing a page should not reload unrelated pages",
Expand All @@ -1579,12 +1581,10 @@
],
"failed": [
"basic HMR, basePath: \"\" Error Recovery should recover after webpack parse error in an imported file",
"basic HMR, basePath: \"\" Error Recovery should recover from errors in getInitialProps in client",
"basic HMR, basePath: \"\" Error Recovery should recover from errors in the render function",
"basic HMR, basePath: \"\" Full reload should warn about full reload in cli output - anonymous page function",
"basic HMR, basePath: \"\" Full reload should warn about full reload in cli output - runtime-error",
"basic HMR, basePath: \"/docs\" Error Recovery should recover after webpack parse error in an imported file",
"basic HMR, basePath: \"/docs\" Error Recovery should recover from errors in getInitialProps in client",
"basic HMR, basePath: \"/docs\" Error Recovery should recover from errors in the render function",
"basic HMR, basePath: \"/docs\" Full reload should warn about full reload in cli output - anonymous page function",
"basic HMR, basePath: \"/docs\" Full reload should warn about full reload in cli output - runtime-error"
Expand Down

0 comments on commit e9104e5

Please sign in to comment.