-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(wrangler): keep wrangler dev alive when a proxied request to the UserWorker fails transiently
#15252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GregoryCollett
wants to merge
3
commits into
cloudflare:main
Choose a base branch
from
GregoryCollett:gc-dev-proxy-transient-fetch-failures
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+194
−74
Open
fix(wrangler): keep wrangler dev alive when a proxied request to the UserWorker fails transiently
#15252
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| "wrangler": patch | ||
| --- | ||
|
|
||
| `wrangler dev` no longer exits when a request to your Worker fails transiently | ||
|
|
||
| Previously, a transient network failure on a single request — most commonly a request arriving just as an idle internal connection was closed, after roughly five seconds without traffic — could take down the whole dev server with an empty `✘ [ERROR]`, leaving the port unbound until restarted. In CI test suites, one such failure caused every remaining test to fail with connection errors. | ||
|
|
||
| `wrangler dev` now automatically retries the affected request if it is safe to repeat (GET and HEAD requests). If a request still fails, it fails individually — the error is logged with the request method and URL — and the dev server keeps serving. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Logged error for a failed dev request shows a blank reason instead of the request details
The failed proxied request is logged (
event.cause.messageatpackages/wrangler/src/api/startDevWorker/DevEnv.ts:202) using the wrong property, so the method, URL, attempt count and underlying error come out blank and the user only sees a generic message with nothing after the colon.Impact: When a request to the Worker fails, the dev server keeps running (good) but the logged error is empty of any useful detail, reproducing the very empty-message symptom this change claims to fix.
Why event.cause.message is empty after the JSON boundary
The ProxyWorker packs the useful text (method, URL, attempt count, underlying
error.message) intomessage.error.messageand posts it as JSON (packages/wrangler/templates/startDevWorker/ProxyWorker.ts:267-275). On the controller sideProxyController.onProxyWorkerMessagecallsemitErrorEvent("Error inside ProxyWorker", message.error)(packages/wrangler/src/api/startDevWorker/ProxyController.ts:478), passing a plainSerializedErrorobject (it crossedJSON.stringify/await req.json(), so it is NOT anErrorinstance).emitErrorEventsetscause: castErrorCause(message.error)(packages/wrangler/src/api/startDevWorker/ProxyController.ts:653). Because the serialized error is notinstanceof Error,castErrorCausereturnsnew Error()with an empty message and stashes the serialized object on.cause(packages/wrangler/src/api/startDevWorker/events.ts:32-41).So in production
event.cause.messageis"", while the real detail lives atevent.cause.cause.message. The new log atDevEnv.ts:201-203interpolates the emptyevent.cause.message, yieldingError inside ProxyWorker (the affected request failed; the dev server continues):with nothing after the colon.The new test
DevEnv.test.ts:107-115masks this because it dispatches anErrorEventwhosecauseis a realnew Error("GET ... Network connection lost.")rather than the empty-wrapperErrorthatcastErrorCauseactually produces in production.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.