Skip to content

fix(hmr): invalidate cached chunks when version tags change - #16548

Merged
JSerFeng merged 1 commit into
mainfrom
fy/hmr-chunk-version-content-hash
Nov 10, 2026
Merged

JSerFeng merged 1 commit into
mainfrom
fy/hmr-chunk-version-content-hash

Conversation

@JSerFeng

Copy link
Copy Markdown
Contributor

Motivation

Adding an export to a module shared by the entry and an async chunk can change the async chunk's HMR version without changing its generated factories. Its content hash stays unchanged, so the render cache reuses a chunk with the old version tag while the runtime expects the new version. Fresh page loads then fail with "Chunk is from another build, and no update leads to it".

Fixes #16542.

Changes

Include the emitted HMR version tag in the JavaScript content hash for chunks carrying HMR version metadata. A tag change now invalidates the rendered asset and updates [contenthash] filenames. Builds without HMR, including production builds, do not gain version metadata.

Add 36 regression scenarios covering JSONP, CommonJS and ESM chunks, both runtime modes, stable and content-hashed filenames, and HMR/development/production builds. Check fresh page loads, HMR application, absence of version metadata without HMR, and stable assets after an unrelated edit.

Validation:

  • Before the fix: all 12 HMR scenarios fail the content-hash assertion; the 24 non-HMR scenarios pass.
  • pnpm run build:binding:dev and pnpm run build:js pass.
  • 180 focused HMR compiler cases (including the 36 new scenarios) and 160 HMR snapshot cases pass.
  • The issue's original reproduction passes with the local build in Chromium: reloading after adding the export still displays APP CHUNK.
  • Rust formatting and diff whitespace checks pass.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T05:36:10.616245Z 19a05fc New commits
🔒 Security Review ✅ Completed 2026-11-10T05:37:58.272640Z 19a05fc New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 19a05fc to test(stats): cover shared issuers in child compilations (#16456) by pshu

🙈 Size remains the same at 68.65MB

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 541.5 KB 0 0
react-10k 5.4 MB 1.3 MB 0 0
react-1k 827.5 KB 225.2 KB 0 0
react-5k 2.6 MB 670.6 KB 0 0
ui-components 4.7 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

@codspeed

codspeed Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 57 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing fy/hmr-chunk-version-content-hash (19a05fc) with main (ced1282)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@JSerFeng
JSerFeng force-pushed the fy/hmr-chunk-version-content-hash branch from d13b085 to 19a05fc Compare November 10, 2026 05:35
@JSerFeng
JSerFeng merged commit b351704 into main Nov 10, 2026
@JSerFeng
JSerFeng deleted the fy/hmr-chunk-version-content-hash branch November 10, 2026 06:20
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.

[Bug]: Page loads fail with "Chunk is from another build" after a module shared by the entry and an async chunk gains an export (2.3.1)

2 participants