Repository navigation
[remote-bindings] Fail RPC binding requests on network errors instead of hanging - #16949
Conversation
… 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 detectedLatest commit: 4b6daee The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
P1: If the replacement |
|
I'm Bonk, and I've done a quick review of your PR. Fixes remote RPC network errors being mistaken for preview reloads.
|
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
…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.
|
Codeowners approval required for this PR:
Show detailed file reviewers |
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.
There was a problem hiding this comment.
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 === proxyDatacorrectly separates a failure against the current preview from one caused by a reload. - The immediate
processQueue()call respects a paused proxy and cannot loop. urlFromPartsanduserWorkerUrlare 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
expectfrom 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
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
Co-authored-by: Ben Dixon <4991309+NuroDev@users.noreply.github.com>
There was a problem hiding this comment.
✅ 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: Thethis.proxyData === proxyDatacheck counts a failure as belonging to the current preview only if nopauseorplayhas replacedproxyDatasince the request was sent. A failure during a pause is requeued, andprocessQueue()returns early while the proxy is paused, so the request is retried on the nextplay. -
ProxyWorker.test.ts: The tests run the realProxyControlleragainst 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
expectfrom 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
## 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>
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
proxyDatathe request was sent with, since everyplaysets a new object. Wrangler's origin check (#14593) wouldn't work here: remote previews keep the same<worker>.<subdomain>.workers.devhost 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
playwould wait for the next request or reload.