Skip to content

fix(vite-plugin): retry transient module-transport failures in the runner worker - #14851

Merged
edmundhung merged 4 commits into
cloudflare:mainfrom
exKAZUu:fix-runner-invoke-retry
Jul 28, 2026
Merged

fix(vite-plugin): retry transient module-transport failures in the runner worker#14851
edmundhung merged 4 commits into
cloudflare:mainfrom
exKAZUu:fix-runner-invoke-retry

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #14849.

Each fetchModule invoke in the runner worker's module-runner transport was a single fetch to the dev server with no retry. If that one fetch failed transiently (e.g. Network connection lost from the loopback keep-alive race in #14848), Vite's module runner cached the rejection, and every request importing the affected module failed for the rest of the dev session — one transient hiccup out of thousands of module fetches permanently bricked the session until a file edit or dev-server restart.

This change retries the invoke fetch up to three times before giving up. The invoke is an idempotent request for module code, so retrying is safe, and it converts a rare transient transport error into a non-event.

This complements the root-cause fix for the specific trigger I could reproduce (#14848 / #14850): even with that fixed, any other short-lived hiccup on the loopback path would still poison the session without a retry.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows: the transient failure needs real socket-pool timing, so it is inherently flaky to assert in CI. Manually verified by instrumenting the runner worker in a real app (details in [vite-plugin] A single transient module-transport failure permanently breaks the dev session #14849): on stock Miniflare, cold starts failed on 1–2 of ~3,000 invokes and the session stayed broken; with this retry applied, the same cold starts complete successfully.
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: dev-only internal transport robustness fix; no user-facing API change.

Open in Devin Review

…nner worker

A single failed fetchModule invoke is cached by Vite's module runner and
poisons the module graph for the rest of the dev session. The invoke is
an idempotent request for module code, so retry it up to three times
before giving up.

Fixes cloudflare#14849
@exKAZUu
exKAZUu requested a review from workers-devprod as a code owner July 26, 2026 01:50
@changeset-bot

changeset-bot Bot commented Jul 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3f166c1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/vite-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@workers-devprod
workers-devprod requested review from a team and edmundhung and removed request for a team July 26, 2026 01:50
@workers-devprod

workers-devprod commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Jul 27, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@14851

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@14851

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@14851

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@14851

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@14851

miniflare

npm i https://pkg.pr.new/miniflare@14851

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@14851

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@14851

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@14851

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@14851

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@14851

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@14851

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@14851

wrangler

npm i https://pkg.pr.new/wrangler@14851

commit: 3f166c1

@edmundhung edmundhung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix.

I think it is fine to merge without test as the retry is hard to replicate in test environment and the change is small enough. Our existing tests should also cover the happy path.

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Jul 28, 2026
@edmundhung

Copy link
Copy Markdown
Member

Don't worry about CI flakes. I will sort them out.

@edmundhung
edmundhung merged commit fb89b72 into cloudflare:main Jul 28, 2026
62 of 63 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[vite-plugin] A single transient module-transport failure permanently breaks the dev session

3 participants