Skip to content

[remote-bindings] Fail RPC binding requests on network errors instead of hanging - #16949

Draft
edmundhung wants to merge 1 commit into
mainfrom
edmundhung/elastic-mendel-71994b
Draft

edmundhung wants to merge 1 commit into
mainfrom
edmundhung/elastic-mendel-71994b

Conversation

@edmundhung

Copy link
Copy Markdown
Member

The remote-bindings proxy decides whether a failed request came from a reloaded preview by comparing the request's full URL with the preview's bare origin. RPC bindings connect to /?MF-Binding=<name>, so every network failure (offline, DNS, TLS) looked like a reload, and the request sat in the retry queue with no error until the next reload, if one ever came.

It now compares the proxyData the request was sent with, since every play sets a new object. Wrangler's origin check (#14593) wouldn't work here: remote previews keep the same <worker>.<subdomain>.workers.dev host across reloads and only change the preview token.


  • 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: bug fix with no change to documented behaviour

… of hanging

The 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 network failure
looked like a reload, and the request waited in the retry queue for a
`play` that never came instead of failing with the error.

Comparing origins, as Wrangler does, 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.
@changeset-bot

changeset-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 737a141

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

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-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

@ask-bonk

ask-bonk Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

P1: If the replacement play has already been handled when the old preview fetch rejects, that play has already drained both queues. The request is then placed in requestRetryQueue after the drain and waits indefinitely for another reload. This becomes reachable for every remote reload now that distinct proxyData identifies reloads despite the unchanged origin.

						this.requestRetryQueue.set(request, deferredResponse);
						this.processQueue();

@ask-bonk

ask-bonk Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

I'm Bonk, and I've done a quick review of your PR.

Fixes remote RPC network errors being mistaken for preview reloads.

  1. P1: Retry can hang if replacement play arrives before the old fetch fails. Suggestion posted: [remote-bindings] Fail RPC binding requests on network errors instead of hanging #16949 (comment)

github run

@pkg-pr-new

pkg-pr-new Bot commented Nov 16, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@16949

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@16949

@cloudflare/config

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

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@16949

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@16949

@cloudflare/pages-shared

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

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@16949

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@16949

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 737a141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

1 participant