Skip to content

Only announce server component changes when compiled output changed - #96783

Closed
gaearon wants to merge 2 commits into
gaearon-turbopack-native-content-hashfrom
gaearon-server-hmr-deletion-announcements
Closed

Only announce server component changes when compiled output changed#96783
gaearon wants to merge 2 commits into
gaearon-turbopack-native-content-hashfrom
gaearon-server-hmr-deletion-announcements

Conversation

@gaearon

@gaearon gaearon commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Stacked on #96248.

In dev with Turbopack, applying a server HMR update ends with telling every connected tab to refetch its RSC payload. But an applied update doesn't necessarily change anything a tab renders. Removing a page is the clearest case: the update just rewrites the removed page's module into a throwing stub inside the merged server chunks —

"code": "((__turbopack_context__, module, exports) => {
  var e = new Error(\"Could not parse module '[project]/app/zz-probe/page.tsx', file not found\");
  e.code = 'MODULE_UNPARSABLE';
  throw e;
})"

— and no other page's output changes. Every tab was still told to refetch. Since the removed-page announcement already makes tabs refetch, deleting one page made every tab refetch twice instead of once.

Messages the server sends for rm app/zz-added/page.tsx while a tab shows /counted, before the fix:

{"type":"removedPage","data":["/zz-added"]}
{"type":"serverComponentChanges"}            ← 2–4ms later, from the HMR apply

after:

{"type":"removedPage","data":["/zz-added"]}

Because the two messages arrive within milliseconds, the browser sometimes handles them as one refetch and sometimes as two, depending on the machine. This is why the refetch-count test could not pin down the removal: idle machines usually saw two fetches, CI machines usually saw one, and the test expected an exact number. That was the Expected: 3, Received: 2 failure every Turbopack CI job showed for the PRs below this one. Since no exact refetch count is correct while the extra announcement exists, the test now also asserts on the announcement itself, which doesn't depend on timing: without this fix it fails every run, on every machine.

The apply loop now decides the same way the "use cache" refresh hash already does one PR down: compare each subscribed entry's compiled-output hash (serverContentHash() from #96248) against a baseline, and announce only when one differs.

  • Baselines are seeded when an entry's change subscription starts, before the entry's first render is underway. An edit landing in the few milliseconds between the two can be absorbed into the baseline, losing one announcement. The refresh-hash baseline one PR down has the same window, and the next change corrects it.
  • A null hash means the entry has no compiled output right now (removed, or failing to build). It keeps the previous baseline, so output that comes back different is still announced.
  • A hash that can't be read counts as changed. The reads go through Promise.allSettled because a rejected read must not take down the apply loop — its failure path re-evaluates every server module.
  • Env-change invalidations announce through a separate path and are unaffected.

Test plan

The first commit extends the refetch-count test with a removal phase — exactly one refetch per addition and one per removal, on both bundlers — and asserts that no serverComponentChanges is announced for either. The test ends by checking the opposite direction too: editing the page the tab is showing must produce exactly one serverComponentChanges and exactly one more refetch. Besides covering the edit path, this proves the message capture works — if the capture silently broke, the "no announcements" assertions would pass without checking anything.

Without the fix, the test fails on Turbopack 3 of 3 runs; webpack passes it unchanged. With the fix, Turbopack passes 3 of 3, and an earlier revision of the same test (without the edit phase) passed 30 consecutive full-suite runs.

Suites covering the changed loop, all green with the fix (locally built binding)
  • route-change-refetch — 30 consecutive Turbopack runs of the counted test green; webpack 3×10/10. The pre-existing "tab stuck on 404 after a page add" flake (the ensurePage/watcher race, being fixed separately) is unaffected: matched warm runs are 10/10 both with and without this fix.
  • server-components-hmr-cache (17) — edits and env changes must still refetch and invalidate
  • middleware-dev-update (4)
  • hmr basic (4), error-recovery (12 + 1 skipped), full-reload (2)
  • cache-components-spurious-cache-invalidation (6, idle and under CPU load)
  • dynamic-optional-routing under experimental Turbopack (33)

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Stats from current PR

🔴 3 regressions

Metric Canary PR Change Trend
node_modules Size 552 MB 553 MB 🔴 +65.8 kB (+0%) ▁▁▁▁▁
Turbo Build Time (cached) 2.883s 3.164s 🔴 +281ms (+10%) ▁▁▂▂█
Webpack Build Time (cached) 24.086s 25.145s 🔴 +1.059s (+4%) ▃▅▄▅█
📊 All Metrics
📖 Metrics Glossary

Dev Server Metrics:

  • Listen = TCP port starts accepting connections
  • First Request = HTTP server returns successful response
  • Cold = Fresh build (no cache)
  • Warm = With cached build artifacts

Build Metrics:

  • Fresh = Clean build (no .next directory)
  • Cached = With existing .next directory

Change Thresholds:

  • Time: Changes < 50ms AND < 10%, OR < 2% are insignificant
  • Size: Changes < 1KB AND < 1% are insignificant
  • All other changes are flagged to catch regressions

⚡ Dev Server

Metric Canary PR Change Trend
Cold (Listen) 813ms 813ms ▁▁▁▁█
Cold (Ready in log) 781ms 800ms ▁▁▁▁█
Cold (First Request) 1.277s 1.356s ▁▁▁▂█
Warm (Listen) 813ms 813ms ▂▂▂▂█
Warm (Ready in log) 787ms 790ms ▁▁▁▁█
Warm (First Request) 1.268s 1.289s ▄▅▅▅▁
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 811ms 812ms █████
Cold (Ready in log) 772ms 774ms ▄▇▅▄█
Cold (First Request) 3.442s 3.411s ▄▇▅▄█
Warm (Listen) 810ms 812ms █████
Warm (Ready in log) 769ms 773ms ▅▇▅▅█
Warm (First Request) 3.418s 3.381s ▄▇▅▄█

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 5.699s 5.978s ▁▁▂▂█
Cached Build 2.883s 3.164s 🔴 +281ms (+10%) ▁▁▂▂█
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 24.757s 24.454s ▄▆▄▅█
Cached Build 24.086s 25.145s 🔴 +1.059s (+4%) ▃▅▄▅█
node_modules Size 552 MB 553 MB 🔴 +65.8 kB (+0%) ▁▁▁▁▁
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles
Canary PR Change
058w61dpm3cqw.js gzip 65.6 kB N/A -
07jdby0ue616s.js gzip 450 B N/A -
0bpdo1ungpa1f.js gzip 156 B N/A -
0c6u57grail3x.js gzip 170 B N/A -
0cz1d0mv5g_q7.js gzip 39.4 kB 39.4 kB
0im0vz0lo815s.js gzip 8.77 kB N/A -
0o_vwr3g7ul4d.js gzip 153 B N/A -
0r0fd4d11wyn4.js gzip 71.5 kB N/A -
0swyji3ow3ejy.js gzip 157 B N/A -
133405p6ewydx.js gzip 10 kB N/A -
17p50_vq5-xc5.js gzip 8.71 kB N/A -
19ccooxgg3ig-.js gzip 158 B N/A -
19xzn89g-pvj8.js gzip 9.45 kB N/A -
1elt1qium-r2m.css gzip 115 B 115 B
1euuepccop6tn.js gzip 157 B N/A -
1ey-k8tr3q-bs.js gzip 10.6 kB N/A -
1tf1phijqlx9j.js gzip 220 B 220 B
1wd1e9uuc4euy.js gzip 8.76 kB N/A -
1x5nn4e-ie-yq.js gzip 157 B N/A -
219oe54sobbj5.js gzip 8.81 kB N/A -
22alyybqz5_09.js gzip 3.57 kB N/A -
28p1njha-2ovo.js gzip 13.6 kB N/A -
29cpgg4v96x1a.js gzip 46.3 kB N/A -
2b-nvb0ybzif_.js gzip 8.7 kB N/A -
2e4bfy2uw7u8k.js gzip 162 B N/A -
2fiblq00c5lus.js gzip 158 B N/A -
2m3bh1binl60-.js gzip 13.2 kB N/A -
2oks0a7s7ajem.js gzip 10.3 kB N/A -
2ro36qy2p7rk3.js gzip 158 B N/A -
36zq1yfgu9pi8.js gzip 158 B N/A -
38-q43pzktqhs.js gzip 1.46 kB N/A -
3cmn6_bzlp40l.js gzip 158 B N/A -
3fw39x1tg924h.js gzip 8.79 kB N/A -
3gb86jnt99vm1.js gzip 159 B N/A -
3kfiy2dr7a5m3.js gzip 5.72 kB N/A -
3l2c-qzlafpi-.js gzip 8.78 kB N/A -
3mrwxzed0ylgv.js gzip 13.1 kB N/A -
3rdf0zyd2dgxs.js gzip 8.76 kB N/A -
41jfc8g2x7su6.js gzip 7.54 kB N/A -
41u5s3oe2-erp.js gzip 2.29 kB N/A -
turbopack-0k..szes.js gzip 3.86 kB N/A -
turbopack-0r..il8_.js gzip 3.86 kB N/A -
turbopack-11..y2yt.js gzip 3.86 kB N/A -
turbopack-15..x7tl.js gzip 3.86 kB N/A -
turbopack-1l..px2j.js gzip 3.86 kB N/A -
turbopack-2f..ri27.js gzip 3.86 kB N/A -
turbopack-2r..9njs.js gzip 3.86 kB N/A -
turbopack-34..buim.js gzip 3.88 kB N/A -
turbopack-3c..fj-u.js gzip 3.86 kB N/A -
turbopack-3h..1sef.js gzip 3.86 kB N/A -
turbopack-3o..trs1.js gzip 3.86 kB N/A -
turbopack-3o..y0rz.js gzip 3.86 kB N/A -
turbopack-3t..mbf1.js gzip 3.86 kB N/A -
turbopack-42..299z.js gzip 3.84 kB N/A -
0-bqn1evm376_.js gzip N/A 159 B -
02lz-0jvjp02x.js gzip N/A 169 B -
093rf1t2n-ajl.js gzip N/A 46.3 kB -
0b87lr4cig17b.js gzip N/A 8.75 kB -
0e1qkafcsotw-.js gzip N/A 8.7 kB -
0j64ls9v56hnd.js gzip N/A 3.56 kB -
0jwho9fkrb_t3.js gzip N/A 2.29 kB -
0masaz6qt9sws.js gzip N/A 10 kB -
0n2f4y98eckf4.js gzip N/A 8.78 kB -
12-pii8wla4es.js gzip N/A 71.6 kB -
1234ksg9gdne_.js gzip N/A 8.77 kB -
17oe55cu76cd7.js gzip N/A 450 B -
1f9vshbsx7xnz.js gzip N/A 152 B -
1ko45a632uro6.js gzip N/A 8.79 kB -
1u5hjpgv9qkjy.js gzip N/A 9.45 kB -
1vo1y77yos8dy.js gzip N/A 155 B -
1zaads01qg38m.js gzip N/A 155 B -
2dcpwnqx1p8a1.js gzip N/A 161 B -
2dt81h56uyprs.js gzip N/A 8.75 kB -
2g2f64lmg3m7w.js gzip N/A 5.73 kB -
2lpk5_hknut8q.js gzip N/A 13.1 kB -
2mt_63jxezrii.js gzip N/A 155 B -
2nx05-6a5iv91.js gzip N/A 157 B -
2tlidw2e-lxb8.js gzip N/A 65.6 kB -
2ugc69z0t0ypz.js gzip N/A 1.46 kB -
2uile-vrx5c0g.js gzip N/A 8.81 kB -
2xhyauod8lfuk.js gzip N/A 8.71 kB -
2z-2x1ptpwnb3.js gzip N/A 10.3 kB -
3cfchh-pop8av.js gzip N/A 156 B -
3i9lo_uk5i3a5.js gzip N/A 155 B -
3lbo1wlhwn240.js gzip N/A 158 B -
3q0h3yzsw1g9v.js gzip N/A 13.2 kB -
3rodp-hyqw7n0.js gzip N/A 13.6 kB -
3t7v1ffjrnh9r.js gzip N/A 7.55 kB -
3wf5ghp1070vm.js gzip N/A 157 B -
3zlop8l06gits.js gzip N/A 158 B -
40fek9ngcsppd.js gzip N/A 10.6 kB -
turbopack-0h..nn85.js gzip N/A 3.86 kB -
turbopack-0n..bhg_.js gzip N/A 3.84 kB -
turbopack-0t..oz0y.js gzip N/A 3.86 kB -
turbopack-15..zlvg.js gzip N/A 3.86 kB -
turbopack-16..z6o3.js gzip N/A 3.86 kB -
turbopack-17..udsh.js gzip N/A 3.86 kB -
turbopack-1l..yn9a.js gzip N/A 3.86 kB -
turbopack-1w..7yzj.js gzip N/A 3.86 kB -
turbopack-2q..0obe.js gzip N/A 3.88 kB -
turbopack-37..mjr_.js gzip N/A 3.86 kB -
turbopack-3h..v1nc.js gzip N/A 3.86 kB -
turbopack-3q..3g8a.js gzip N/A 3.86 kB -
turbopack-3s..5gi4.js gzip N/A 3.86 kB -
turbopack-43..stil.js gzip N/A 3.86 kB -
Total 451 kB 451 kB ✅ -31 B

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 777 B 779 B
Total 777 B 779 B ⚠️ +2 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 435 B 429 B 🟢 6 B (-1%)
Total 435 B 429 B ✅ -6 B
Build Cache
Canary PR Change
00000001.sst gzip 12.2 MB 12.6 MB 🔴 +394 kB (+3%)
00000002.sst gzip 13 MB 13.7 MB 🔴 +741 kB (+6%)
00000003.sst gzip 15.5 MB 15.3 MB 🟢 197 kB (-1%)
00000004.sst gzip 14.4 MB 13.4 MB 🟢 963 kB (-7%)
00000005.sst gzip 2.8 MB 10.2 MB 🔴 +7.4 MB (+264%)
00000006.sst gzip 10.2 MB 2.8 MB 🟢 7.38 MB (-72%)
00000007.sst gzip 58 B 58 B
00000008.meta gzip 89 B 89 B
00000009.meta gzip 298 kB 298 kB
00000010.meta gzip 298 kB 298 kB
00000011.meta gzip 298 kB 298 kB
00000012.sst gzip 50.9 kB 51.1 kB
00000013.sst gzip 1.88 MB 1.91 MB 🔴 +27.8 kB (+1%)
00000014.sst gzip 58 B 58 B
00000015.meta gzip 116 B 116 B
00000016.meta gzip 324 kB 324 kB
00000017.meta gzip 404 kB 406 kB
00000018.sst gzip 51.7 kB 51.8 kB
00000019.sst gzip 1.38 MB 1.39 MB 🔴 +8.35 kB (+1%)
00000020.sst gzip 58 B 58 B
00000021.meta gzip 116 B 116 B
00000022.meta gzip 324 kB 324 kB
00000023.meta gzip 370 kB 370 kB
00000024.sst gzip 51.7 kB 51.8 kB
00000025.sst gzip 1.38 MB 1.39 MB 🔴 +8.54 kB (+1%)
00000026.sst gzip 58 B 58 B
00000027.meta gzip 116 B 116 B
00000028.meta gzip 324 kB 324 kB
00000029.meta gzip 370 kB 370 kB
00000030.sst gzip 51 kB 51 kB
00000031.sst gzip 1.38 MB 1.39 MB 🔴 +8.54 kB (+1%)
00000032.sst gzip 58 B 58 B
00000033.meta gzip 116 B 116 B
00000034.meta gzip 324 kB 324 kB
00000035.meta gzip 370 kB 370 kB
00000036.sst gzip 51.6 kB 51.7 kB
00000037.sst gzip 1.38 MB 1.39 MB 🔴 +8.48 kB (+1%)
00000038.sst gzip 58 B 58 B
00000039.meta gzip 116 B 116 B
00000040.meta gzip 324 kB 324 kB
00000041.meta gzip 370 kB 370 kB
CURRENT gzip 24 B 24 B
LOG gzip 664 B 672 B 🔴 +8 B (+1%)
Total 80.1 MB 80.2 MB ⚠️ +68.2 kB

📦 Webpack

Client

Main Bundles
Canary PR Change
3322-HASH.js gzip 65.1 kB N/A -
4191.HASH.js gzip 169 B N/A -
7920-HASH.js gzip 4.67 kB N/A -
9784-HASH.js gzip 5.63 kB N/A -
b1ad9f4c-HASH.js gzip 63.2 kB N/A -
framework-HASH.js gzip 59.7 kB 59.7 kB
main-app-HASH.js gzip 253 B 253 B
main-HASH.js gzip 40 kB 40 kB
webpack-HASH.js gzip 1.68 kB 1.68 kB
3577.HASH.js gzip N/A 168 B -
578-HASH.js gzip N/A 65.9 kB -
8590-HASH.js gzip N/A 5.6 kB -
9750-HASH.js gzip N/A 4.68 kB -
a8984546-HASH.js gzip N/A 63.2 kB -
Total 241 kB 241 kB ⚠️ +734 B
Polyfills
Canary PR Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Total 39.4 kB 39.4 kB
Pages
Canary PR Change
_app-HASH.js gzip 194 B 193 B
_error-HASH.js gzip 181 B 182 B
css-HASH.js gzip 334 B 331 B
dynamic-HASH.js gzip 1.81 kB 1.81 kB
edge-ssr-HASH.js gzip 255 B 253 B
head-HASH.js gzip 349 B 351 B
hooks-HASH.js gzip 382 B 384 B
image-HASH.js gzip 581 B 582 B
index-HASH.js gzip 260 B 259 B
link-HASH.js gzip 2.48 kB 2.48 kB
routerDirect..HASH.js gzip 317 B 318 B
script-HASH.js gzip 384 B 386 B
withRouter-HASH.js gzip 316 B 315 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Total 7.95 kB 7.95 kB ⚠️ +1 B

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 129 kB 128 kB
page.js gzip 294 kB 294 kB
Total 422 kB 423 kB ⚠️ +343 B
Middleware
Canary PR Change
middleware-b..fest.js gzip 616 B 617 B
middleware-r..fest.js gzip 156 B 156 B
middleware.js gzip 45.7 kB 45.3 kB
edge-runtime..pack.js gzip 842 B 842 B
Total 47.4 kB 46.9 kB ✅ -422 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 718 B 718 B
Total 718 B 718 B
Build Cache
Canary PR Change
0.pack gzip 4.83 MB 4.82 MB
index.pack gzip 123 kB 123 kB
index.pack.old gzip 123 kB 123 kB
Total 5.07 MB 5.07 MB ✅ -3.72 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 374 kB 374 kB
app-page-exp..prod.js gzip 207 kB 207 kB
app-page-tur...dev.js gzip 374 kB 374 kB
app-page-tur..prod.js gzip 206 kB 206 kB
app-page-tur...dev.js gzip 370 kB 370 kB
app-page-tur..prod.js gzip 204 kB 204 kB
app-page.run...dev.js gzip 370 kB 370 kB
app-page.run..prod.js gzip 204 kB 204 kB
app-route-ex...dev.js gzip 83.3 kB 83.3 kB
app-route-ex..prod.js gzip 56.4 kB 56.4 kB
app-route-tu...dev.js gzip 83.3 kB 83.3 kB
app-route-tu..prod.js gzip 56.4 kB 56.4 kB
app-route-tu...dev.js gzip 82.9 kB 82.9 kB
app-route-tu..prod.js gzip 56.2 kB 56.2 kB
app-route.ru...dev.js gzip 82.8 kB 82.8 kB
app-route.ru..prod.js gzip 56.2 kB 56.2 kB
dev-validati...dev.js gzip 133 kB 133 kB
dev-validati...dev.js gzip 133 kB 133 kB
dev-validati...dev.js gzip 131 kB 131 kB
dev-validati...dev.js gzip 131 kB 131 kB
dist_client_...dev.js gzip 324 B 324 B
dist_client_...dev.js gzip 326 B 326 B
dist_client_...dev.js gzip 318 B 318 B
dist_client_...dev.js gzip 317 B 317 B
pages-api-tu...dev.js gzip 46 kB 46 kB
pages-api-tu..prod.js gzip 34.3 kB 34.3 kB
pages-api.ru...dev.js gzip 46 kB 46 kB
pages-api.ru..prod.js gzip 34.3 kB 34.3 kB
pages-turbo....dev.js gzip 54.8 kB 54.8 kB
pages-turbo...prod.js gzip 39.9 kB 39.9 kB
pages.runtim...dev.js gzip 54.8 kB 54.8 kB
pages.runtim..prod.js gzip 39.9 kB 39.9 kB
server.runti..prod.js gzip 67 kB 67 kB
use-cache-pr...dev.js gzip 72.3 kB 72.3 kB
use-cache-pr...dev.js gzip 72.4 kB 72.4 kB
use-cache-pr...dev.js gzip 70.6 kB 70.6 kB
use-cache-pr...dev.js gzip 70.6 kB 70.6 kB
Total 4.1 MB 4.1 MB ⚠️ +5 B
📝 Changed Files (4 files)

Files with changes:

  • pages-api-tu..ntime.dev.js
  • pages-turbo...ntime.dev.js
  • pages-api.runtime.dev.js
  • pages.runtime.dev.js
View diffs
pages-api-tu..ntime.dev.js

Diff too large to display

pages-turbo...ntime.dev.js

Diff too large to display

pages-api.runtime.dev.js

Diff too large to display

pages.runtime.dev.js

Diff too large to display

📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/92279da08d9281522238fef3b4e318c5aead7db0/next

Commit: 92279da

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Failing test suites

Commit: 92279da | About building and testing Next.js

pnpm test-dev test/e2e/app-dir/navigation/navigation.test.ts (job)

  • app dir - navigation > middleware redirect > should change browser location when router.refresh() gets a redirect response (DD)
Expand output

● app dir - navigation › middleware redirect › should change browser location when router.refresh() gets a redirect response

expect(received).toBe(expected) // Object.is equality

Expected: "http://localhost:40939/redirect-on-refresh/dashboard"
Received: "http://localhost:40939/redirect-on-refresh/auth"

  1034 |       const browser = await next.browser('/redirect-on-refresh/auth')
  1035 |       await retry(async () =>
> 1036 |         expect(await browser.url()).toBe(
       |                                     ^
  1037 |           next.url + '/redirect-on-refresh/dashboard'
  1038 |         )
  1039 |       )

  at toBe (e2e/app-dir/navigation/navigation.test.ts:1036:37)
  at retry (lib/next-test-utils.ts:868:14)
  at Object.<anonymous> (e2e/app-dir/navigation/navigation.test.ts:1035:7)

@gaearon
gaearon force-pushed the gaearon-server-hmr-deletion-announcements branch 2 times, most recently from 4b7b46e to d738b8f Compare August 6, 2026 01:50
@gaearon
gaearon marked this pull request as ready for review August 6, 2026 01:51
@gaearon
gaearon force-pushed the gaearon-server-hmr-deletion-announcements branch from d738b8f to f21feef Compare August 6, 2026 02:33
@gaearon
gaearon force-pushed the gaearon-server-hmr-deletion-announcements branch from f21feef to 1509660 Compare August 6, 2026 03:18
@gaearon
gaearon force-pushed the gaearon-server-hmr-deletion-announcements branch from 1509660 to c34972e Compare August 6, 2026 03:23
@gaearon
gaearon force-pushed the gaearon-server-hmr-deletion-announcements branch from c34972e to 4afac2f Compare August 6, 2026 03:56
@gaearon
gaearon force-pushed the gaearon-server-hmr-deletion-announcements branch from 4afac2f to 850fdab Compare August 6, 2026 04:02
@gaearon
gaearon requested review from bgw, Copilot and wbinnssmith and removed request for Copilot August 6, 2026 04:09
@gaearon
gaearon force-pushed the gaearon-server-hmr-deletion-announcements branch from 850fdab to 43d4532 Compare August 6, 2026 08:03
@gaearon
gaearon force-pushed the gaearon-server-hmr-deletion-announcements branch 2 times, most recently from 8024ca8 to a54aaf6 Compare August 6, 2026 09:00
gaearon added 2 commits August 6, 2026 13:40
Adding or removing a page changes no other page's server components, so an
open tab must refetch exactly once per addition (the added-page
announcement) and once per removal (the removed-page announcement), with no
serverComponentChanges announcement for either. This extends the counted
refetch test with a removal phase and pins the announcement itself.

On Turbopack the removal half fails: removing a page that has been built
applies a server HMR update, and applying any update announces changed
server components, so every tab is told to refetch again for a removal that
changed nothing it renders. Whether that shows up as a third refetch or
folds into the announcement's refetch depends on how close together the two
messages reach the browser, so counting fetches alone can't pin it down —
asserting on the announcement makes the failure deterministic.

An edit to the page the tab is showing must still announce, exactly once,
with exactly one more refetch. Besides pinning the edit path, this keeps
the zero-announcements assertion honest: if the capture ever stops seeing
the messages, the edit phase fails instead of the empty check passing
vacuously.
Applying a server HMR update ended with telling every connected tab to
refetch its RSC payload. But an applied update doesn't necessarily change
what any page renders: removing a page that the server has built applies an
update that rewrites the removed module into a throwing stub inside the
merged server chunks, and no other entry's output changes. Every tab still
refetched for it — and since the removed-page announcement makes tabs
refetch already, a removal cost each tab two refetches (or one, depending
on how close together the two messages arrived, which is what made the
refetch-count test unpinnable).

The apply loop now decides the way the HMR refresh hash already does:
compare each subscribed server entry's compiled output hash against a
baseline, and announce only when one differs. Baselines are seeded when an
entry's change subscription starts, before the entry's first render is
underway (an edit landing in the milliseconds between those two can be
absorbed into the baseline and miss one announcement — the same window the
refresh-hash baseline a PR down already has, corrected by the next change
either way). A null hash (the entry was removed, or currently fails to
build) keeps the previous baseline, so output coming back different is
still announced. A hash that can't be read at all counts as changed — the
announcement is what every apply sent unconditionally before this gate.
Env-change invalidations announce through their own path and are
unaffected.

This flips the previous commit's test green on Turbopack: an open tab now
refetches exactly once per page addition and once per removal, with no
server-component-changes announcement for either, matching webpack. Also
still green: server-components-hmr-cache (17 — edits and env changes must
still refetch and invalidate), middleware-dev-update (4), the basic hmr,
error-recovery, and full-reload suites (4, 12, 2), the use cache
spurious-invalidation suite (6), and the full route-change-refetch suite
(10).
@gaearon
gaearon force-pushed the gaearon-server-hmr-deletion-announcements branch from a54aaf6 to 92279da Compare August 6, 2026 12:46
@gaearon

gaearon commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

May revisit this in the future, for now don't want to spend more time on it

@gaearon gaearon closed this Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant