Skip to content

[wrangler] Keep request-scoped proxy errors non-fatal - #15207

Open
exKAZUu wants to merge 5 commits into
cloudflare:mainfrom
exKAZUu:fix-proxy-worker-request-errors
Open

[wrangler] Keep request-scoped proxy errors non-fatal#15207
exKAZUu wants to merge 5 commits into
cloudflare:mainfrom
exKAZUu:fix-proxy-worker-request-errors

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #15203.

Refs #14926 and #14641.

Customer Summary

  • Keeps wrangler dev running when proxying one local request fails, instead of terminating the development session and its dependent test runner.
  • Reports the actual request error (for example, Network connection lost.) rather than an empty fatal diagnostic.
  • No configuration or migration is required.

Technical Summary

  • Treats ProxyWorker fetch errors as request-scoped failures and logs them without dispatching a fatal controller error event.
  • Adds a controller-level regression test verifying both the diagnostic and the absence of a fatal event.
  • Adds a patch changeset for Wrangler.

Why

  • ProxyWorker already rejects the affected request. Promoting its serialized error to the dev environment's fatal error bus unnecessarily shuts down wrangler dev, which then causes parallel Playwright processes to receive SIGTERM.
  • Keeping the failure request-scoped preserves the useful diagnostic while allowing subsequent requests and the local development session to continue.

Testing

  • pnpm -w test:ci -F wrangler -- ProxyController.test.ts
  • pnpm prettify
  • pnpm check (203 tasks passed)
  • Reproduced the failure with Wrangler 4.123.0 using an assets Worker and concurrent POST request bodies: the stock process emitted an empty fatal error and exited after Network connection lost.
  • Repeated the same workload against the local build for 6,000 POST requests, then confirmed a subsequent GET returned HTTP 200 and the process remained alive.

  • 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 only changes internal local-development error classification; no public API or configuration changes.

A picture of a cute animal (not mandatory, but encouraged)


Open in Devin Review

@changeset-bot

changeset-bot Bot commented Aug 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 00bc2e1

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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Aug 15, 2026
@workers-devprod
workers-devprod requested review from a team and emily-shen and removed request for a team August 15, 2026 13:28
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/tidy-pandas-smile.md: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/api/startDevWorker/ProxyController.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/startDevWorker/ProxyController.ts: [@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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Aug 15, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

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

@cloudflare/codemods

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

@cloudflare/config

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 00bc2e1

yashau added a commit to yashau/prick that referenced this pull request Aug 19, 2026
The e2e job died mid-run and passed on a re-run. It was not flaky
infrastructure and it was not the OOM killer: `wrangler dev` exits on a
SINGLE failed proxied request, and reports it as `✘ [ERROR]` with an
empty message.

Wrangler forwards every request through its own ProxyWorker. When that
inner fetch rejects, the ProxyWorker reports it to the ProxyController,
`DevEnv.handleErrorEvent` finds no matching non-fatal case and re-emits
it as a top-level `error`; the dev command is
`await events.once(devEnv, "teardown")`, and Node's `events.once`
rejects on `error`, so the command throws and the process exits 1. The
cause crossed a Worker boundary, so it is a plain object rather than an
Error, and `castErrorCause` wraps it in `new Error()` -- message "".
Hence a fatal exit that names nothing.

The rejection is `Network connection lost.`, raised when a client
disconnects while its request body is still uploading. Playwright does
that every time it closes a page with a form POST in flight. Confirmed
by reduction: five aborted uploads against a bare Worker kill wrangler
4.121.0 with the exact CI signature, and survive it patched.

So the failure was one browser-side race taking down the server for the
rest of the suite -- seventy `ERR_CONNECTION_REFUSED` failures, three
attempts each, none of them naming the event.

Patch wrangler with upstream's own fix (cloudflare/workers-sdk#15207,
issue #15203): report the failed request and keep serving. Two call
sites, because wrangler bundles the ProxyController twice. Remove the
patch when a release carries the fix -- a version bump that leaves it
here fails the install rather than applying quietly.

`patches/**` joins the js paths filter: a patched dependency is
application behaviour, and editing it must run the suite that proves it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
yashau added a commit to yashau/prick that referenced this pull request Aug 19, 2026
The e2e job died mid-run and passed on a re-run. It was not flaky
infrastructure and it was not the OOM killer: `wrangler dev` exits on a
SINGLE failed proxied request, and reports it as `✘ [ERROR]` with an
empty message.

Wrangler forwards every request through its own ProxyWorker. When that
inner fetch rejects, the ProxyWorker reports it to the ProxyController,
`DevEnv.handleErrorEvent` finds no matching non-fatal case and re-emits
it as a top-level `error`; the dev command is
`await events.once(devEnv, "teardown")`, and Node's `events.once`
rejects on `error`, so the command throws and the process exits 1. The
cause crossed a Worker boundary, so it is a plain object rather than an
Error, and `castErrorCause` wraps it in `new Error()` -- message "".
Hence a fatal exit that names nothing.

The rejection is `Network connection lost.`, raised when a client
disconnects while its request body is still uploading. Playwright does
that every time it closes a page with a form POST in flight. Confirmed
by reduction: five aborted uploads against a bare Worker kill wrangler
4.121.0 with the exact CI signature, and survive it patched.

So the failure was one browser-side race taking down the server for the
rest of the suite -- seventy `ERR_CONNECTION_REFUSED` failures, three
attempts each, none of them naming the event.

Patch wrangler with upstream's own fix (cloudflare/workers-sdk#15207,
issue #15203): report the failed request and keep serving. Two call
sites, because wrangler bundles the ProxyController twice. Remove the
patch when a release carries the fix -- a version bump that leaves it
here fails the install rather than applying quietly.

`patches/**` joins the js paths filter: a patched dependency is
application behaviour, and editing it must run the suite that proves it.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@anthonywu

Copy link
Copy Markdown

+💯 priority to fix. This is blocking us in development. In the meantime, we're using the patch.

@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/tidy-pandas-smile.md: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/api/startDevWorker/ProxyController.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/startDevWorker/ProxyController.ts: [@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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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.

wrangler dev exits with "Error inside ProxyWorker / Network connection lost" on POST requests with a body when assets is configured

3 participants