Unverified Commit 8aa42519 authored by Hannes Bornö's avatar Hannes Bornö Committed by GitHub

Reload on server component change (#45268)

If there's an error when hard navigating to a page, the overlay in `packages/react-dev-overlay` is rendered instead of the one in `next`. This can cause you to get stuck if it's a server component because currently `packages/react-dev-overlay` ignores server component change events. This adds a reload for this case. The next step is probably to make sure the `app` overlay is rendered for errors during hard navigations as well.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent c45481be
......@@ -275,6 +275,8 @@ function processMessage(e: any) {
}
case 'serverComponentChanges': {
// Server component changes don't apply to `pages`.
// TODO-APP: Remove reload once the correct overlay is rendered on initial page load in app dir
window.location.reload()
return
}
default: {
......
......@@ -914,5 +914,22 @@ for (const variant of ['default', 'turbo']) {
await cleanup()
})
test.each([['server'], ['client']])(
'%s component can recover from error thrown in the module',
async (type: string) => {
const { session, cleanup } = await sandbox(next, undefined, '/' + type)
await next.patchFile('index.js', "throw new Error('module error')")
expect(await session.hasRedbox(true)).toBe(true)
await next.patchFile(
'index.js',
'export default function Page() {return <p>hello world</p>}'
)
expect(await session.hasRedbox(false)).toBe(false)
await cleanup()
}
)
})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment