Repository navigation
[vite-plugin] Retry v1 remote binding requests after preview reloads - #16899
petebacondarwin wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: fc531d2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Codeowners approval required for this PR:
|
|
@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 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. |
commit: |
There was a problem hiding this comment.
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.
|
|
||
| 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. |
There was a problem hiding this comment.
🔍 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
✅ 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
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
playmessage. Its GET/HEAD retry was left queued until another request or reload. Drain the retry queue immediately, allowingprocessQueue()to wait if the proxy is still paused.The Vite plugin's retained
startRemoteProxySession→DevEnv→ProxyControllerpath 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, andpnpm test:ci; the retained proxy regression covers both event orderings. The test initially needed adjustment for the package's ES library andnoImplicitOverride; final checks are recorded after those adjustments. Formatting andgit diff --checkpass. Credentialed remote E2E tests are not run.Note
This is a contribution from an AI agent: Codex.