Skip to content

test(dev): expect preserved hot.data in hmr-whole-chain-dispose#10380

Merged
shulaoda merged 1 commit into
mainfrom
fix/preserve-hot-data-across-hmr
Jul 22, 2026
Merged

test(dev): expect preserved hot.data in hmr-whole-chain-dispose#10380
shulaoda merged 1 commit into
mainfrom
fix/preserve-hot-data-across-hmr

Conversation

@h-a-n-a

@h-a-n-a h-a-n-a commented Jul 22, 2026

Copy link
Copy Markdown
Member

Description

The hmr-whole-chain-dispose browser fixture runs on Vite's full-bundle client (the provisioned vite/ checkout, vitejs/vite rolldown-canary), not rolldown's native runtime — see the note in full-bundle-dev-environment.ts. That client's handleModuleCacheRemoval was recently fixed to preserve import.meta.hot.data across a module's HMR generations, matching Vite's documented contract:

The import.meta.hot.data object is persisted across different instances of the same updated module.
https://vite.dev/guide/api-hmr#hot-data (see vitejs/vite#23001)

On rolldown-canary the client (renamed to bundledDevHmrClient.ts) now does:

handleModuleCacheRemoval(id: string): void {
  const disposer = this.disposeMap.get(id)
  if (disposer) {
    disposer(this.dataMap.get(id))   // existing bag, not a fresh {}
  }
}

But this test + fixtures still asserted the old "each generation gets a fresh data bag" behavior, so once the client started preserving, CI failed:

FAIL playground/hmr-whole-chain-dispose/__tests__/hmr-whole-chain-dispose.spec.ts
  > every re-executed module disposes, each generation gets a fresh data bag
AssertionError: expected 'baz-own-write' to be null

('baz-own-write' is a direct hot.data write from generation 0 that correctly survived into generation 1.)

Change

Align the fixtures and assertions with the preserved-data contract:

  • Rename the leak probe (which meant "a direct write that must NOT survive") to own, and assert each module's own direct hot.data write is read back by the next generation (own === \${id}-own-write``).
  • gen0 bags are still empty (gen: null, own: null); the disposer-written gen counter still advances 1 → 2 — those were already passing and are unchanged.
  • Whole-chain dispose coverage is untouched: every re-executed module in the evicted chain (baz, bar, and the boundary foo) still disposes each generation (3, then 6).

Validation

  • vp check (lint/format) via the commit hook.
  • The browser E2E itself is verified by CI (node-dev-server-test); it requires the provisioned vite/ checkout + native build, so it was not run locally. Expectations were derived from the preserved-data semantics and confirmed against rolldown-canary's current bundledDevHmrClient.ts and the exact CI failure value.

Note: the separate Vite Test job failing on the same runs is the Vite-side manifestation of the same behavior change and is not addressed here (it lives in the vite/ checkout, not this repo).

The `hmr-whole-chain-dispose` browser fixture runs on Vite's full-bundle
client (the `vite/` checkout, `rolldown-canary`). That client now preserves
`import.meta.hot.data` across a module's HMR generations — the disposer
receives the existing bag and direct writes into `hot.data` survive — which
is Vite's documented contract (vitejs/vite#23001).

The test and fixtures still asserted the old "fresh data bag per generation"
behavior, so it failed once the client started preserving:
`expected 'baz-own-write' to be null`.

Rewrite the fixtures and assertions to expect preservation: rename the
`leak` probe to `own` and assert each module's own direct write is read back
by the next generation. Whole-chain dispose coverage (foo, bar, and the
boundary all dispose each generation) is unchanged.
@netlify

netlify Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 28e49c0
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6a606565c14bc400076ed702

@h-a-n-a
h-a-n-a requested a review from shulaoda July 22, 2026 06:39

shulaoda commented Jul 22, 2026

Copy link
Copy Markdown
Member

Merge activity

  • Jul 22, 6:45 AM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jul 22, 6:45 AM UTC: shulaoda added this pull request to the Graphite merge queue.

@shulaoda
shulaoda merged commit d69b2b4 into main Jul 22, 2026
37 of 38 checks passed
@shulaoda
shulaoda deleted the fix/preserve-hot-data-across-hmr branch July 22, 2026 06:46
Brooooooklyn added a commit that referenced this pull request Jul 22, 2026
Catches the branch up to main so CI can run again (the PR was CONFLICTING
against the advanced base) and pulls in the fixes that target this branch's
red dev-server tests:

  #10380  test(dev): expect preserved hot.data in hmr-whole-chain-dispose
          — Vite's rolldown-canary client now preserves import.meta.hot.data;
            this branch had the stale pre-#10380 assertion. Taken from main.
  #10363/#10381  tokio runtime acquire/release pairing + release-on-reject.

Conflicts resolved to this branch's side (--ours) — the branch's shared
tokio-free runtime supersedes main's tokio-refcount work:
  - dev-engine.ts / experimental.ts / rolldown-build.ts / watch/watcher.ts:
    main wraps shutdownAsyncRuntime() in try/finally (#10381). This branch
    already releases via the RuntimeLease abstraction inside a `finally`
    (release-on-reject guaranteed) plus AggregateError cleanup — a strict
    superset, so #10381 is subsumed. Verified main touched only the
    lease/startAsyncRuntime lines in these files.
  - crates/rolldown_binding/src/lib.rs + generated binding.d.cts: main adds
    the ACTIVE_TASK_COUNT tokio refcount to start/shutdown_async_runtime
    (#10363). This branch removed tokio, so those exports are compatibility
    no-ops (napi env lifecycle owns teardown; the legacy tokio-WASI path uses
    the old binding's own code). Verified main's changes here are entirely
    the refcount + its doc comments.

No lockfile/catalog conflicts: main touched no manifests in aa73a68..c07a55c.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01T34fMrYCf2V13Mg8BKmnda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants