Skip to content

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

Merged
edmundhung merged 4 commits into
mainfrom
edmundhung/elastic-mendel-71994b
Nov 17, 2026
Merged

edmundhung merged 4 commits into
mainfrom
edmundhung/elastic-mendel-71994b

Conversation

@edmundhung

@edmundhung edmundhung commented Nov 16, 2026 •

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.

A request requeued this way is now retried right away, as Wrangler does since #16862. Otherwise a failure handled after the replacement play would wait for the next request or reload.


  • 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: 4b6daee

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: 4b6daee

…ped connection

The previous tests ran the bundled Worker in a Node `vm` with stubbed
globals, mocked fetch rejections, and assertions on the private retry
queue. They now start the real ProxyController in Miniflare in front of a
local server that drops the connection, and assert only on what callers
see: the response and the reported error.

The second test checks that a failure from a replaced preview on the same
host is treated as a reload, which an origin check would get wrong.
@edmundhung
edmundhung marked this pull request as ready for review November 17, 2026 11:00
@workers-devprod
workers-devprod requested review from a team and NuroDev and removed request for a team November 17, 2026 11:01
@workers-devprod

workers-devprod commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

clanky-the-clanker[bot]

This comment was marked as resolved.

Now that a reload is detected by a new proxyData rather than a changed
URL, a root-path GET whose old-preview connection fails after the
replacement `play` has already drained the queues is requeued with
nothing left to drain it. Before, the URLs matched and the request
failed instead. Drain right after requeueing, as Wrangler does since
#16862; processQueue still waits while the proxy is paused.

Replace the POST reload test with a GET where `play` completes before
the old connection drops, and say in the changeset that only GET and
HEAD requests are retried.

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

This review, of 567ed799

✅ Approved — No findings: the proxyData identity check and the immediate retry of requeued requests are correct and covered by tests, and the earlier changeset note is fixed.

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

The patch changeset covers the packages that consume remote-bindings. The change only affects how the proxy behaves during local development, and integration tests cover it.


🔒 Security: ✅ LGTM

No security concerns.


📖 AGENTS.md: ✅ LGTM

No issues.


📋 Code Quality: ✅ LGTM

  • The identity check this.proxyData === proxyData correctly separates a failure against the current preview from one caused by a reload.
  • The immediate processQueue() call respects a paused proxy and cannot loop.
  • urlFromParts and userWorkerUrl are still used, so the change leaves no dead code.
  • The tests use the real ProxyController in front of a server that drops the connection, and they take expect from the test context.

⚡ Performance: ✅ LGTM

Each GET or HEAD request is retried at most once per reload. A failed retry is reported rather than requeued, so there is no retry loop.


📝 Documentation: ✅ LGTM

The changeset now says that only GET and HEAD requests are retried after a reload.


Reviewed commit: 567ed799

@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

Co-authored-by: Ben Dixon <4991309+NuroDev@users.noreply.github.com>
@edmundhung
edmundhung enabled auto-merge (squash) November 17, 2026 12:23

@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 — No findings. The proxyData identity check and the immediate retry of requeued requests are correct and covered by tests, and the changeset wording now matches the behaviour.

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

Overall risk: Low. The change only affects how remote bindings behave during local development. Integration tests that use a local server dropping the connection cover it.


🔒 Security: ✅ LGTM

No security concerns.


📖 AGENTS.md: ✅ LGTM

No issues.


📋 Code Quality: ✅ LGTM

  • ProxyWorker.ts: The this.proxyData === proxyData check counts a failure as belonging to the current preview only if no pause or play has replaced proxyData since the request was sent. A failure during a pause is requeued, and processQueue() returns early while the proxy is paused, so the request is retried on the next play.

  • ProxyWorker.test.ts: The tests run the real ProxyController against a local server that drops the connection. They cover two cases:

    • a failure against the current preview, which returns a 500 and emits an error event;
    • a failure caused by a reload, where the new preview serves the retry.

    The tests take expect from the test context.


⚡ Performance: ✅ LGTM

No performance concerns. A requeued request is retried at most once per reload.


📝 Documentation: ✅ LGTM

The updated changeset says that only GET and HEAD requests interrupted by a reload are retried, which matches the code.


Reviewed commit: 4b6daee6

@edmundhung
edmundhung merged commit 110c162 into main Nov 17, 2026
84 checks passed
@edmundhung
edmundhung deleted the edmundhung/elastic-mendel-71994b branch November 17, 2026 12:42
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in workers-sdk Nov 17, 2026
brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Nov 22, 2026
## pnpm-workspace.yaml (default)

## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `@cloudflare/vitest-plugin` | 1.8.4 | 1.8.5 | patch |
| `@cloudflare/workers-types` | 5.20261118.1 | 5.20261119.1 | minor |
| `miniflare` | 5.20261117.0-beta | 5.20261118.0-beta | minor |
| `wrangler` | 4.164.0 | 4.165.0 | minor |

## Release Notes

<details>
<summary><b>@<!---->cloudflare/vitest-plugin</b> (1.8.4 →
1.8.5)</summary>

### Patch Changes

- [#17003](cloudflare/workers-sdk#17003)
[`3595295`](cloudflare/workers-sdk@3595295)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update `DEFAULT_COMPAT_DATE` to 2026-11-18

Use the bundled workerd release's compatibility date by default when
scaffolding new projects or when no compatibility date is configured.

- [#16949](cloudflare/workers-sdk#16949)
[`110c162`](cloudflare/workers-sdk@110c162)
Thanks [@<!---->edmundhung](https://github.com/edmundhung)! - Fail
remote RPC binding requests on network errors instead of hanging

Remote bindings that connect over RPC treated every network failure,
such as being offline, a DNS or TLS error, as a preview reload. The
request then waited silently for a reload that never came. These
requests now fail with the error, while GET and HEAD requests
interrupted by an actual reload are still retried.

- [#14578](cloudflare/workers-sdk#14578)
[`6750663`](cloudflare/workers-sdk@6750663)
Thanks [@<!---->penalosa](https://github.com/penalosa)! - Fix `Dynamic
require` errors when importing packages from ES modules

Importing these packages in a Node.js ES module could fail with `Dynamic
require of "..." is not supported` when a dependency loaded a Node.js
built-in. These imports now work without requiring a CommonJS wrapper.

- Updated dependencies
[[`24bd3c3`](cloudflare/workers-sdk@24bd3c3),
[`0a4315f`](cloudflare/workers-sdk@0a4315f),
[`8f26e90`](cloudflare/workers-sdk@8f26e90),
[`3595295`](cloudflare/workers-sdk@3595295),
[`3595295

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/%40cloudflare/vitest-plugin%401.8.5)

</details>

<details>
<summary><b>miniflare</b> (5.20261117.0-beta →
5.20261118.0-beta)</summary>

### Patch Changes

- [#16954](cloudflare/workers-sdk#16954)
[`0a4315f`](cloudflare/workers-sdk@0a4315f)
Thanks [@<!---->mkuritsu](https://github.com/mkuritsu)! - Local Browser
Run sessions now use Chrome 152

Local Browser Run bindings now run Chrome 152.0.7977.64, the same
version that Browser Run uses in production. Miniflare will download
Chrome 152 the first time you start a local Browser Run session after
you upgrade.

- [#17003](cloudflare/workers-sdk#17003)
[`3595295`](cloudflare/workers-sdk@3595295)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update `DEFAULT_COMPAT_DATE` to 2026-11-18

Use the bundled workerd release's compatibility date by default when
scaffolding new projects or when no compatibility date is configured.

- [#17003](cloudflare/workers-sdk#17003)
[`3595295`](cloudflare/workers-sdk@3595295)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update dependencies of "miniflare", "wrangler"

  The following dependency versions have been updated:

  | Dependency                | From          | To            |
  | ------------------------- | ------------- | ------------- |
  | @<!---->cloudflare/workers-types | ^5.20261117.1 | ^5.20261118.1 |
  | workerd                   | 1.20261117.1  | 1.20261118.1  |

- [#14578](cloudflare/workers-sdk#14578)
[`6750663`](cloudflare/workers-sdk@6750663)
Thanks [@<!---->penalosa](https://github.com/penalosa)! - Fix startup
failures in Miniflare and C3 when loading ESM dependencies

Miniflare and `create-cloudflare` can now load dependencies that use
Node.js's `createRequire()` without failing on an invalid file URL. This
prevents these dependencies from causing an error before

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/miniflare%405.20261118.0-beta)

</details>

<details>
<summary><b>wrangler</b> (4.164.0 → 4.165.0)</summary>

### Minor Changes

- [#10598](cloudflare/workers-sdk#10598)
[`24bd3c3`](cloudflare/workers-sdk@24bd3c3)
Thanks [@<!---->Ehbraheem](https://github.com/Ehbraheem)! - Add a new
`--force` flag to `d1 migrations apply` which skips the interactive
confirmation and applies any pending migrations non-interactively. This
is useful for CI and automation.

  Usage example:

  ```
  wrangler d1 migrations apply <db> --remote --force
  ```

  Fixes #5017

### Patch Changes

- [#16019](cloudflare/workers-sdk#16019)
[`8f26e90`](cloudflare/workers-sdk@8f26e90)
Thanks [@<!---->penalosa](https://github.com/penalosa)! - Correct the
dry-run setup message to say "exiting now" instead of "existing now".

The previous wording contained a typo and appeared in Wrangler setup
output and other consumers of shared autoconfig.

- [#17003](cloudflare/workers-sdk#17003)
[`3595295`](cloudflare/workers-sdk@3595295)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update `DEFAULT_COMPAT_DATE` to 2026-11-18

Use the bundled workerd release's compatibility date by default when
scaffolding new projects or when no compatibility date is configured.

- [#17003](cloudflare/workers-sdk#17003)
[`3595295`](cloudflare/workers-sdk@3595295)
Thanks [@<!---->dependabot](https://github.com/apps/dependabot)! -
Update dependencies of "miniflare", "wrangler"

  The following dependency versions have been updated:

  | Dependency                | From          | To            |
  | ------------------------- | ------------- | ------------- |
  | @<!---->cloudflare/workers-types | ^5.20261117.1 | ^5.20261118.1 |
  | workerd                   | 1.20261117.1  | 1.20261118.1  |

- [#16719](https://github.com/cl

…[full
notes](https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.165.0)

</details>

---
*This PR was auto-generated by
[catalog-update-action](https://github.com/brandhaug/catalog-update-action).*

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

3 participants