Skip to content

feat(bundled-dev): support worker file update accepted by HMR - #23068

Merged
sapphi-red merged 3 commits into
mainfrom
07-27-fix_worker_serve_workers_updated_through_an_hmr_patch_in_bundled_dev
Jul 28, 2026
Merged

sapphi-red merged 3 commits into
mainfrom
07-27-fix_worker_serve_workers_updated_through_an_hmr_patch_in_bundled_dev

Conversation

@shulaoda

@shulaoda shulaoda commented Jul 26, 2026 •

Copy link
Copy Markdown
Member

Problem

In bundled dev (experimental.bundledDev), editing a worker source leaves the page running the old worker. The request for the new worker file returns 200 with text/html (the SPA fallback), so the browser cannot parse it as a module worker and only reports an error event with an undefined message. The network panel looks fine, so this is easy to miss.

Affects both new Worker(new URL('./w.js', import.meta.url)) and import Worker from './w.js?worker', and a worker spawned from inside another worker.

It only reproduces when the importing module is an HMR boundary. Without one the edit escalates to a full reload, which rebuilds and emits the worker. React Fast Refresh makes self-accepting importers the norm, so real apps sit on the failing path.

Cause

vite:worker splits the work across two phases:

  • load resolves the final worker URL and writes it into the module
  • generateBundle hands the worker bytes to the bundler

An HMR patch is generated without a generate phase, so only the first half runs. Worker filenames carry a content hash, so an edited worker gets a new filename that was never emitted.

vite:asset avoids this by calling emitFile during load, before deriving the URL from it.

Related Issues

Part of the Full Bundle Mode plugin coverage work (rolldown/rolldown#10469).

@shulaoda
shulaoda requested review from h-a-n-a and sapphi-red July 26, 2026 22:29
@shulaoda
shulaoda requested a review from sapphi-red July 27, 2026 07:30
@sapphi-red sapphi-red changed the title fix(worker): serve workers updated through an HMR patch in bundled dev feat(bundled-dev): support worker file update accepted by HMR Jul 28, 2026
@sapphi-red
sapphi-red enabled auto-merge (squash) July 28, 2026 05:25
@sapphi-red
sapphi-red merged commit 0d04351 into main Jul 28, 2026
@sapphi-red
sapphi-red deleted the 07-27-fix_worker_serve_workers_updated_through_an_hmr_patch_in_bundled_dev branch July 28, 2026 05:32
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.

2 participants