next.js
d52d36d3 - gracefully handle client router segment mismatches (#60141)

Commit
2 years ago
gracefully handle client router segment mismatches (#60141) ### What? Next.js throws a hard `SEGMENT MISMATCH` error when the reducers were unable to apply the a patch to the router tree from the server response. ### How? Rather than crashing the router, this will treat segment mismatches as a MPA navigation, to restore the client router into a working state. ### Test Plan If there are specific scenarios where Next.js throws this error, it should most likely be fixed in Next and not in user-land. Since it's not currently obvious what scenarios will trigger this error, this PR serves to recover from a mismatch more gracefully and provides some debug information rather than crashing the application. As such, there's no easy way to create an E2E test for this and I've instead opted for a simple unit test. Closes NEXT-1878 [slack x-ref](https://vercel.slack.com/archives/C017QMYC5FB/p1704214439768469) [slack x-ref](https://vercel.slack.com/archives/C03KAR5DCKC/p1702565978694519) --------- Co-authored-by: JJ Kasper <jj@jjsweb.site>
Author
Parents
Loading