Skip to content

fix(dev): reload the page when an HMR update fails after merging its edit - #11031

Merged
graphite-app[bot] merged 1 commit into
mainfrom
fix/dev-resend-failed-hmr-update
Oct 2, 2026
Merged

graphite-app[bot] merged 1 commit into
mainfrom
fix/dev-resend-failed-hmr-update

Conversation

@h-a-n-a

@h-a-n-a h-a-n-a commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

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.

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"]
Loading

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

h-a-n-a commented Sep 29, 2026 •

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add 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.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-dev-resend-failed-hmr-update-rolldown-rs.voidzero-docs.workers.dev (commit 68b285a)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://075c77e8-rolldown-rs.voidzero-docs.workers.dev 68b285a 2026-10-02T08:53:22.809Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://93e05e25-rolldown-rs.voidzero-docs.workers.dev cf6326d 2026-10-02T07:35:03.397Z Visit the dashboard ↗
  • Build: In progress 🔵

View logs ↗
1a4f85c 2026-10-02T07:32:47.504Z View logs ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://12c733f5-rolldown-rs.voidzero-docs.workers.dev 1fb505e 2026-10-02T06:45:25.284Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://6c269466-rolldown-rs.voidzero-docs.workers.dev 5a9c2e2 2026-10-01T16:34:05.916Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://8943dc15-rolldown-rs.voidzero-docs.workers.dev 9832e2f 2026-10-01T15:11:43.317Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://6e18f832-rolldown-rs.voidzero-docs.workers.dev 4e79b4a 2026-10-01T12:28:42.670Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://ddfa3dea-rolldown-rs.voidzero-docs.workers.dev e80f93e 2026-10-01T11:54:56.979Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://b815742a-rolldown-rs.voidzero-docs.workers.dev 2f182b4 2026-10-01T10:35:42.752Z Visit the dashboard ↗
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://5ae307a4-rolldown-rs.voidzero-docs.workers.dev ff1da06 2026-10-01T09:35:51.111Z Visit the dashboard ↗

View all previews: View all previews ↗

@h-a-n-a
h-a-n-a force-pushed the fix/dev-resend-failed-hmr-update branch from c336a36 to 85fa58a Compare October 1, 2026 07:54
@h-a-n-a
h-a-n-a force-pushed the fix/dev-payload-stamp-order branch from 60e556e to 5ff3742 Compare October 1, 2026 07:54
@h-a-n-a
h-a-n-a force-pushed the fix/dev-resend-failed-hmr-update branch 2 times, most recently from e8dee78 to af1a2ed Compare October 1, 2026 08:27
@h-a-n-a
h-a-n-a force-pushed the fix/dev-payload-stamp-order branch from 5ff3742 to b8244ff Compare October 1, 2026 08:27
@h-a-n-a
h-a-n-a force-pushed the fix/dev-resend-failed-hmr-update branch 3 times, most recently from 2a3c674 to ff1da06 Compare October 1, 2026 09:33
@h-a-n-a
h-a-n-a force-pushed the fix/dev-payload-stamp-order branch from b8244ff to 45b987f Compare October 1, 2026 09:33
@h-a-n-a
h-a-n-a changed the base branch from fix/dev-payload-stamp-order to graphite-base/11031 October 1, 2026 10:33
@h-a-n-a
h-a-n-a force-pushed the graphite-base/11031 branch from 45b987f to 5b5a838 Compare October 1, 2026 10:33
@h-a-n-a
h-a-n-a force-pushed the fix/dev-resend-failed-hmr-update branch from ff1da06 to 2f182b4 Compare October 1, 2026 10:33
@h-a-n-a
h-a-n-a changed the base branch from graphite-base/11031 to fix/dev-lazy-walk-through-shipped October 1, 2026 10:33
@h-a-n-a
h-a-n-a force-pushed the fix/dev-resend-failed-hmr-update branch from 2f182b4 to e80f93e Compare October 1, 2026 11:52
@h-a-n-a h-a-n-a changed the title fix(dev): send an HMR update again after it failed to render fix(dev): reload the page when an HMR update fails after merging its edit Oct 1, 2026
@h-a-n-a
h-a-n-a force-pushed the fix/dev-resend-failed-hmr-update branch 6 times, most recently from 3942d1b to 5a9c2e2 Compare October 1, 2026 16:29
@h-a-n-a
h-a-n-a marked this pull request as ready for review October 2, 2026 05:25
@h-a-n-a
h-a-n-a requested a review from shulaoda as a code owner October 2, 2026 05:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@codspeed

codspeed Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing fix/dev-resend-failed-hmr-update (cf6326d) with main (f647b4e)2

Open in CodSpeed

Footnotes

  1. 10 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. ↩

  2. No successful run was found on main (5c7d9da) during the generation of this report, so f647b4e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@h-a-n-a
h-a-n-a force-pushed the fix/dev-resend-failed-hmr-update branch from 5a9c2e2 to 1fb505e Compare October 2, 2026 06:43
@graphite-app
graphite-app Bot changed the base branch from fix/dev-lazy-walk-through-shipped to graphite-base/11031 October 2, 2026 07:27
@graphite-app
graphite-app Bot force-pushed the graphite-base/11031 branch from 5b5a838 to 5c7d9da Compare October 2, 2026 07:32
@graphite-app
graphite-app Bot force-pushed the fix/dev-resend-failed-hmr-update branch from 1fb505e to 1a4f85c Compare October 2, 2026 07:32
@graphite-app
graphite-app Bot changed the base branch from graphite-base/11031 to main October 2, 2026 07:33
@graphite-app
graphite-app Bot force-pushed the fix/dev-resend-failed-hmr-update branch from 1a4f85c to cf6326d Compare October 2, 2026 07:33
@netlify

netlify Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 68b285a
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6abf708d42116100083f6d8c

h-a-n-a commented Oct 2, 2026 •

Copy link
Copy Markdown
Member Author

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)
@graphite-app
graphite-app Bot force-pushed the fix/dev-resend-failed-hmr-update branch from cf6326d to 68b285a Compare October 2, 2026 08:51
@graphite-app
graphite-app Bot merged commit 68b285a into main Oct 2, 2026
37 checks passed
@graphite-app
graphite-app Bot deleted the fix/dev-resend-failed-hmr-update branch October 2, 2026 08:55
Brooooooklyn added a commit that referenced this pull request Oct 2, 2026
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
graphite-app Bot pushed a commit that referenced this pull request Oct 2, 2026
## 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)
@rolldown-guard rolldown-guard Bot mentioned this pull request Oct 7, 2026
shulaoda added a commit that referenced this pull request Oct 7, 2026
## [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]>
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.

2 participants