next.js
5c765987 - Fix which pages the dev server announces as added or removed

Commit
36 days ago
Fix which pages the dev server announces as added or removed Both bundlers computed the added/removed page lists wrong, in opposite directions. Turbopack compared the new route keys against the entry maps in `currentEntrypoints` — but those key App Router entries by page name ("/blog/page"), not by route ("/blog"), so for app routes the names never matched: every update announced all existing app routes as added and their page names as removed. Each announcement makes every connected tab refetch, so a single page add refetched every tab five times in a two-route app, growing with the route count. The diff now compares against the previous route keys, which also matches the naming webpack sends and the Pages Router client compares against. webpack entered its announcement branch only when `prevSortedRoutes.every((val, idx) => val === sortedRoutes[idx])` failed — a prefix comparison. A new route that sorts after all existing ones leaves the old list a prefix of the new one, so ADDED_PAGE was silently never sent for it. That was masked by page adds also being treated as env changes, which made browsers refetch anyway; with that false alarm removed (separately), a tab showing a 404 would no longer pick up the newly added page. The comparison now also checks the length. With both fixed, boot announces nothing on either bundler (the first route list is not a change; Turbopack previously announced every route once at startup).
Author
Committer
Parents
Loading