Repository navigation
fix(dev): reload the page when an HMR update fails after merging its edit - #11031
Conversation
How to use the Graphite Merge QueueAdd the label graphite: merge-when-ready to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
c336a36 to
85fa58a
Compare
60e556e to
5ff3742
Compare
e8dee78 to
af1a2ed
Compare
5ff3742 to
b8244ff
Compare
2a3c674 to
ff1da06
Compare
b8244ff to
45b987f
Compare
45b987f to
5b5a838
Compare
ff1da06 to
2f182b4
Compare
2f182b4 to
e80f93e
Compare
3942d1b to
5a9c2e2
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a9c2e2b00
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Merging this PR will not alter performance
Comparing Footnotes
|
5a9c2e2 to
1fb505e
Compare
5b5a838 to
5c7d9da
Compare
1fb505e to
1a4f85c
Compare
1a4f85c to
cf6326d
Compare
✅ Deploy Preview for rolldown-rs canceled.
|
Merge activity
|
…edit (#11031) ## Problem An HMR update that failed in the middle was lost. 1. An edit is merged into the module graph. 2. Building the patch then fails, for example because a `sourcemapPathTransform` callback throws. 3. No tab gets the edit. 4. The next update does not send it either, because the graph already has it. The tabs keep the old code. A failure before the merge, such as a syntax error, was never a problem: the edit is not in the graph yet, so the next update retries it. ## Fix The bundler remembers that an update was lost. Then the next build task reloads every tab and runs a full build, whatever kind of task it is. A successful full build clears this state, and later edits are hot updates again. ```mermaid flowchart LR fail["patch fails after the merge"] --> next["next build task"] next --> reload["reload every tab + full build"] reload --> ok["full build succeeds: back to hot updates"] ``` Vite ignores an update with no changed files, and a full build has none. So the reload lists `*` as its changed file. This can go away once Vite accepts a reload with no changed files. ## Tests The dev test client now works like a real tab: - It keeps running the output it loaded at its last reload, not the newest output on disk. - It reloads only after a successful build, as Vite does. Before, a missing reload could not fail a test. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
cf6326d to
68b285a
Compare
Conflicts and follow-ups: - internal-docs/dev-engine/design.md: ours added principle "5. Quiesce before terminal cleanup", main added the "Lost HMR updates" section (#11031); kept both, principle 5 stays under Design principles, the new section follows it. - .github/workflows/ci.yml, reusable-wasi.yml (auto-merged, follow-up): main moved setup-vp to vite-plus 1.0.0 (#11056); our native-async-runtime jobs and the release-threaded WASI job still pinned 0.2.1, now 1.0.0, and the two ci.yml jobs move from setup-vp v1.18.0 to main's v1.21.1 pin. - crates/rolldown{,_dev,_testing} overlap files auto-merged cleanly: main's lost_hmr_update flag (#11031) sits next to our close state; the reload upgrade in bundling_task.rs keeps our DevCallbackResult error path. No loader or binding change after regen (native, wasi, wasi-single, native). Lanes: lint-node/lint-rust/lint-repo pass; just test-rust 2574 passed 0 failed; native test:main 1644 passed (+131 from main's new behavior tests); ROLLDOWN_WASI_TEST=1 test:main 1611 passed; single test:wasi 1579 passed; test:wasi-threaded MT and CT 5 passed each; lifecycle MT/CT 9/9; crash latch 12 PASS; pool preload default and single 16 PASS each; browser build:debug, workerd packed consumer, wasi packed consumer (node 24 + 20.20.2), browser-tests webcontainer-fallback 1/1 and browser 1/1 pass; release-threaded: crash latch 12, preload 16, wasi-threaded 5, load-failure loop 1500/1500, widened loop 480/480. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01T34fMrYCf2V13Mg8BKmnda
## Problem Adding an import could break a hot update. 1. `heavy.js` is in the module graph, but only through an `import()` that tab B never called. Tab B does not have it. 2. An edit adds `import './heavy.js'` to `hmr.js`. 3. The patch includes `hmr.js` but not `heavy.js`, because `heavy.js` is not new and does not import the changed module. 4. Tab B re-runs `hmr.js`, which throws `MissingFactoryError`. The page keeps the old code and does not reload. ```mermaid flowchart LR hmr["hmr.js — edited"] -- "new import" --> heavy["heavy.js — tab B never got it"] ``` ## Fix The patch now also sends the modules that an edit newly imports, and their imports, when the tab does not have them. Old imports are not checked again: the tab already ran them. If the patch fails after the edit is merged, the page reloads instead (#11031), so a new import is never lost. Part of #10039 (review list item 3). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
## [1.2.13] - 2026-10-07 ### 🚀 Features - rolldown_plugin_vite_import_glob: follow file creation and deletion via hotUpdate (#10550) by @shulaoda - inline-common-chunks: deduplicate shared code along known loading paths (#11093) by @hyfdev - rolldown_plugin_vite_import_glob: record a matcher per glob call in dev (#10592) by @shulaoda - rolldown_plugin_vite_import_glob: watch the directory each glob reads (#10549) by @shulaoda - watch: hand watch.exclude to notify as its ignore filter (#11008) by @shulaoda - dev: add `experimental.devMode.hotUpdate` option (#11123) by @h-a-n-a ### 🐛 Bug Fixes - renamer: check the printed name of namespace-alias imports for captures (#11129) by @IWANABETHATGUY - devtools: honor `devtools.sessionId` by @Brooooooklyn - renamer: keep a renamed nested binding off its module's top-level bindings (#11128) by @IWANABETHATGUY - dev: keep `this` undefined when calling an imported function in HMR patches and lazy chunks (#11126) by @h-a-n-a - dev: read string-named imports correctly in HMR patches and lazy chunks (#11127) by @h-a-n-a - sanitize preserveModules chunk names after resolving the relative path (#11087) by @waltuov - keep the `with` clause on bare external imports (#11100) by @IWANABETHATGUY - generator: filter DISABLE_JS_HOOK bits from generated HookUsage (#10346) by @Brooooooklyn - dev: make the module factory async for top-level await (#11118) by @h-a-n-a - node: give each renderChunk call its own meta object (#11115) by @Brooooooklyn - honor `externalLiveBindings` for imported exports (#11048) by @camc314 - dev: keep a late payload from replacing newer module code (#11030) by @h-a-n-a - binding: use-after-free in async `transform` with a `TsconfigCache` (#11080) by @shulaoda - fail on chunk syntax errors and escape export names once (#11051) by @hyfdev - dev: ship newly imported modules the client never received (#11029) by @h-a-n-a - code-splitting: avoid cycles from redundant re-export initialization (#11073) by @hyfdev - link: treat re-exports of the same external binding as one export (#11069) by @IWANABETHATGUY - escape namespace properties in IIFE and UMD output (#11085) by @hyfdev - escape dependency paths in CJS and UMD output (#11084) by @hyfdev - use computed access for arbitrary import names (#11083) by @hyfdev - generate valid bindings for shimmed exports (#11082) by @hyfdev - dev: reload the page when an HMR update fails after merging its edit (#11031) by @h-a-n-a - dev/lazy: ship the deps of a module that a patch shipped but never ran (#11028) by @h-a-n-a - code-splitting: don't move init calls in front of unwrapped JSON modules (#11062) by @IWANABETHATGUY - escape export names in `defineProperty` calls (#11047) by @camc314 ### 📚 Documentation - say the CLI bundles multiple configs one after another (#11111) by @Brooooooklyn - add `renderChunk` hook filter docs (#11065) by @sapphi-red ### ⚡ Performance - use `concat_string!` instead of `format!` for plain string joins (#11139) by @IWANABETHATGUY - utils: evaluate each `concat_string!` argument once (#11105) by @IWANABETHATGUY - json: escape `JSON.parse` string with `json-escape-simd` (#11104) by @IWANABETHATGUY - unwrap JSON modules with a non-object root (#11066) by @IWANABETHATGUY ### 🧪 Testing - inline-common-chunks: fix flaky inlineCommonChunks concurrent imports (#11088) by @hyfdev ### ⚙️ Miscellaneous Tasks - deps: upgrade oxc to 0.153.0 (#11109) by @camc314 - update pnpm to v12 (#10876) by @btea - deps: update pnpm to v11.28.0 (#11049) by @renovate[bot] - deps: update rollup submodule for tests to v4.64.0 (#11116) by @rolldown-guard[bot] - deps: update napi (#11137) by @renovate[bot] - scripts: spawn the rolldown CLI without a shell in setup-vite (#10875) by @Brooooooklyn - deps: bump `@napi-rs/wasm-runtime` to `~1.2.5` (#11117) by @shulaoda - deps: update napi (#11108) by @renovate[bot] - deps: update taiki-e/install-action action to v2.87.22 (#11096) by @renovate[bot] - deps: update npm packages (#11095) by @renovate[bot] - deps: update rust crates (#11097) by @renovate[bot] - deps: update napi (#11063) by @renovate[bot] - deps: update dependency rust to v1.99.0 (#11071) by @renovate[bot] - deps: update dependency vite-plus to v1 (#11056) by @renovate[bot] Co-authored-by: shulaoda <[email protected]>

Problem
An HMR update that failed in the middle was lost.
sourcemapPathTransformcallback throws.A failure before the merge, such as a syntax error, was never a problem: the edit is not in the graph yet, so the next update retries it.
Fix
The bundler remembers that an update was lost. Then the next build task reloads every tab and runs a full build, whatever kind of task it is. A successful full build clears this state, and later edits are hot updates again.
Vite ignores an update with no changed files, and a full build has none. So the reload lists
*as its changed file. This can go away once Vite accepts a reload with no changed files.Tests
The dev test client now works like a real tab:
Before, a missing reload could not fail a test.
🤖 Generated with Claude Code