Skip to content

[vite-plugin] Retry v1 remote binding requests after preview reloads - #16899

Open
petebacondarwin wants to merge 2 commits into
codex/vite-v1-backport-16838from
codex/vite-v1-backport-16862
Open

petebacondarwin wants to merge 2 commits into
codex/vite-v1-backport-16838from
codex/vite-v1-backport-16862

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Backports #16862 to the existing retained remote-bindings ProxyWorker. During a remote binding session update, an old preview request can fail after the replacement preview's play message. Its GET/HEAD retry was left queued until another request or reload. Drain the retry queue immediately, allowing processQueue() to wait if the proxy is still paused.

The Vite plugin's retained startRemoteProxySession → DevEnv → ProxyController path bundles this template directly. Upgrading installed Wrangler cannot fix this copy. The change modifies that retained template and adds two tests against its bundled code for failure before and after resume. No absent Wrangler source or tests are restored. The resumed case fails before the fix and both cases pass afterwards. No dependency upgrades are required.

Registered in native GitHub stack #16900, after #16861 and before the publication-blocked Artifacts default draft #16898. This fix can merge with the existing published dependencies; #16898 remains draft pending npm publication.

Validation: pnpm build, pnpm check, and pnpm test:ci; the retained proxy regression covers both event orderings. The test initially needed adjustment for the package's ES library and noImplicitOverride; final checks are recorded after those adjustments. Formatting and git diff --check pass. Credentialed remote E2E tests are not run.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this fixes an internal retry race without changing the configuration API.

Note

This is a contribution from an AI agent: Codex.

@changeset-bot

changeset-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fc531d2

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 November 13, 2026 14:07
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler

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

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 2 potential issues.

Devin Review

Comment thread .changeset/v1-remote-proxy-retries.md Resolved
@petebacondarwin

Copy link
Copy Markdown
Contributor Author

@petebacondarwin (verified author of #16862) and @edmundhung (verified human ant-core member; approved the original November 12 at 15:06:18Z, before merge): please check this v1 adaptation and approve it if it looks good.

The retained private remote-bindings package bundles its own ProxyWorker through startRemoteProxySession → DevEnv → ProxyController. This existing template has the same stranded-retry gap; a Wrangler dependency bump cannot fix it. This PR changes only that retained implementation, adds two tests against its bundled code, and supplies a plugin patch changeset. No absent public package source/tests are restored. The resumed-order regression fails before the fix; both orderings pass afterwards. Build, all 58 checks and the full package suites pass (including 267 plugin and 40 remote-bindings tests).

Native GitHub stack #16900 puts this PR above #16861 and below the publication-blocked Artifacts draft #16898. This fix uses the already published dependencies and can merge without waiting for that draft's release.

@pkg-pr-new

pkg-pr-new Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/@cloudflare/vite-plugin@16899

commit: fc531d2

@clanky-the-clanker clanky-the-clanker 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.

Superseded by the review of fc531d2b.

This review, of 11f378b1

✅ Approved — Minimal, correct fix for the retry-queue race, with tests covering both event orderings and an accurate changeset; no issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

Risk: Low. The changeset is a patch bump for @cloudflare/vite-plugin.


🔒 Security: ✅ LGTM

No security concerns.


📖 AGENTS.md: ✅ LGTM

Follows the repository conventions: the test uses the Vitest test-context expect, imports Node built-ins with the node: prefix, and the change ships with a plugin changeset.


📋 Code Quality: ✅ LGTM

Calling processQueue() right after requeueing is safe: it returns early while paused and drains immediately once resumed. The tests cover both orderings and check that the queue ends up empty.


⚡ Performance: ✅ LGTM

No performance concerns. The retry is bounded and cannot loop forever.


📝 Documentation: ✅ LGTM

The changeset accurately describes the fix.


Reviewed commit: 11f378b1

The retained ProxyWorker treated a failed fetch as stale (from a reloaded
preview) whenever the request's full URL differed from the preview's bare
origin. RPC bindings connect to `/?MF-Binding=<name>`, so every failure
looked like a reload. Now that a requeued request is retried immediately,
a preview that keeps failing made the request retry in a loop.

Comparing origins, as Wrangler does on main, doesn't work here: remote
previews keep the same `<worker>.<subdomain>.workers.dev` host across
reloads and only change the preview token. Compare the proxyData the
request was sent with instead, since every `play` sets a new object.

@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 found 1 potential issue.

Devin Review


Retry remote binding requests when a replacement preview is already ready

A retriable request could remain queued if the old preview connection failed after a remote binding session update completed. Drain the retained remote binding proxy's retry queue immediately so requests finish without waiting for another request or reload. Requests that fail on the current preview now return the error instead of hanging.

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.

🔍 Internal mechanics in user-facing changelog

The changeset includes internal retry-queue mechanics, contrary to the changeset guidance. The surrounding explanation already conveys the user-facing benefit: requests finish without another request or reload.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@clanky-the-clanker clanky-the-clanker 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.

✅ Approved — The retry-queue drain and the new check on the proxyData object are correct, and the retry is bounded by preview reloads. Tests cover both event orderings and failures from the current preview; no issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

Risk: Low. This is a focused retry fix with a patch changeset for @cloudflare/vite-plugin.


🔒 Security: ✅ LGTM

No security concerns.


📖 AGENTS.md: ✅ LGTM

The change follows the repository conventions: the tests use Vitest test-context expect and import Node built-ins with the node: prefix, and the plugin change ships with a changeset.


📋 Code Quality: ✅ LGTM

this.proxyData === proxyData at ProxyWorker.ts:160 correctly recognises failures from an earlier preview. pause clears proxyData, and each play assigns a new object. A failure from the current preview is reported and rejected instead of retried. Requests other than GET and HEAD still get a 503. The tests cover both orderings and the current-preview failure case, and they follow the repository's test conventions.


⚡ Performance: ✅ LGTM

A request is retried only after a pause or play changes proxyData. A second failure with no new reload is rejected, so the number of retries is limited by the number of preview reloads.


📝 Documentation: ✅ LGTM

No issues found.


Reviewed commit: fc531d2b

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.

3 participants