Skip to content

[wrangler] Log ProxyWorker request error details at debug level - #15207

Merged
cjol merged 19 commits into
cloudflare:mainfrom
exKAZUu:fix-proxy-worker-request-errors
Sep 25, 2026
Merged

cjol merged 19 commits into
cloudflare:mainfrom
exKAZUu:fix-proxy-worker-request-errors

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Refs #15203, #14926, #14641.

Since #15252, a failed request proxied to the local Worker is logged and wrangler dev keeps running. That log shows only the error message, though, such as Network connection lost.. The stack and cause chain, which are the only clues to why the connection failed, aren't logged even with --log-level debug.

This PR:

  • logs the rehydrated error (stack and cause chain) at debug level in DevEnv's handler for Error inside ProxyWorker, the same way the other non-fatal ProxyController errors are logged;
  • removes the fallback to cause.cause.message, left over from before [wrangler] Preserve serialized error details in castErrorCause #14906. castErrorCause now preserves the message itself, and .cause holds the real underlying cause, so the fallback could report the wrong message.

  • 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: only debug-level log output changes; no public API or configuration changes.

Open in Devin Review

@changeset-bot

changeset-bot Bot commented Aug 15, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 294f30a

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/workers-sdk/@cloudflare/autoconfig@15207

@cloudflare/build-output-utils

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

@cloudflare/codemods

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

@cloudflare/config

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

@cloudflare/containers-shared

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

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/runtime-types

npm i https://pkg.pr.new/cloudflare/workers-sdk/@cloudflare/runtime-types@15207

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 294f30a

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.

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

✅ Devin Review: No Issues Found

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

Open in Devin Review

@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[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@workers-devprod

workers-devprod commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/steady-proxy-requests.md: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/api/startDevWorker/DevEnv.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/startDevWorker/DevEnv.ts: [@cloudflare/wrangler]

devin-ai-integration[bot]

This comment was marked as resolved.

@exKAZUu exKAZUu changed the title [wrangler] Keep request-scoped proxy errors non-fatal [wrangler] Log ProxyWorker request error details at debug level Sep 15, 2026
@GregoryCollett

Copy link
Copy Markdown
Contributor

The improvement here seems extremely sensible. I can definitely get behind this!

@workers-devprod

workers-devprod commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@cjol
cjol removed the request for review from emily-shen September 22, 2026 16:58

@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

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Sep 22, 2026
@cjol
cjol merged commit 805af2f into cloudflare:main Sep 25, 2026
53 checks passed
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.

5 participants