rsnext/test
Zack Tanner c98d2b927d
fix: handle 404 errors in HotReload client (#51637)
### What?
In dev mode, routing to a 404 page will result in an infinite redirect
cycle. This PR is an attempt to bring back similar functionality
currently implemented in the [pages
router.](https://github.com/vercel/next.js/blob/canary/packages/next/src/client/dev/on-demand-entries-client.ts#L41-L59)

### Why?
When the `pong` event (emitted from `onHMR`) occurs on a page that
doesn't exist, it will result in frequent calls to
`router.fastRefresh()`. Because the server response is an error, it'll
trigger a mpa navigation
[here](61ab4aadec/packages/next/src/client/components/router-reducer/fetch-server-response.ts (L115-L117)),
which is treated as an external route
[here](61ab4aadec/packages/next/src/client/components/router-reducer/reducers/fast-refresh-reducer.ts (L45-L53))
(and thus the window is reloaded)

In the case where you're on the page and it goes away, since we don't
have access to `__NEXT_DATA__`, I opted to use the dispatcher which will
trigger the parent `NotFoundBoundary`. This part felt a little awkward
-- I'm open to suggestions on a better way to handle this.

Closes NEXT-1299
Fixes #50585

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-23 16:30:48 -07:00
..
.stats-app Alias next/server for edge runtime (#50268) 2023-05-24 15:34:29 -07:00
__mocks__ [edge] bump @edge-runtime/* package suite (#49092) 2023-05-31 08:03:20 +00:00
development refactor tests for readability (#51051) 2023-06-21 19:47:21 +00:00
e2e fix: handle 404 errors in HotReload client (#51637) 2023-06-23 16:30:48 -07:00
examples feat(cli): introduce --tailwind flag (#46927) 2023-03-16 16:06:27 +01:00
integration type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00
lib type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00
production type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00
unit fix: eslint not ignoring "/app" (#50261) 2023-05-26 16:27:42 +00:00
.gitignore ci(workflow): enable test trace upload (#51107) 2023-06-12 17:14:13 +00:00
jest-setup-after-env.ts type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00
jest.d.ts type check tests (and convert next-test-utils.js to ts) (#51071) 2023-06-23 17:42:50 +00:00
readme.md refactor: split up CONTRIBUTING.md (#40515) 2022-09-16 14:54:58 -07:00
test-file.txt

See Testing for more information on how you can run/write/debug tests for Next.js.