fix(dev): clear stale interception rewrites on HMR update to prevent accumulation#91364
Open
aleewains wants to merge 4 commits intovercel:canaryfrom
Open
fix(dev): clear stale interception rewrites on HMR update to prevent accumulation#91364aleewains wants to merge 4 commits intovercel:canaryfrom
aleewains wants to merge 4 commits intovercel:canaryfrom
Conversation
Author
|
Hi, I'm an external contributor and the CI checks require maintainer |
Author
|
I've added a regression test that simulates 3 HMR file saves and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes interception routes breaking on every HMR file save in Next.js 16.
Why
In
setup-dev-bundler.ts, interception route rewrites are pushed intobeforeFileson every HMRaggregatedevent without clearing old entriesfirst. The (.) markers stacking up on every save makes dev pretty painful since you have to do a full refresh each time. This causes entries to accumulate on every save:
[(.)users/[id]][(.)users/[id], (.)users/[id]][(.)users/[id], (.)users/[id], (.)users/[id]]The duplicate rewrites corrupt pathname matching, producing paths like
/users/(.)(.)(.)1, which then throws:How
Added
isInterceptionRouteRewrite()helper togenerate-interception-routes-rewrites.ts— identifies rewritesgenerated from interception routes by checking for the
NEXT_URLheader in the
hasarray.In
setup-dev-bundler.ts, filter out stale interception rewritesbefore pushing fresh ones on each HMR update.
Testing
Closes #91265