Repository navigation
fix(ext/fetch): reject transport failures with Node's "fetch failed" shape - #35618
Merged
Merged
Conversation
…shape When a fetch transport failure occurs (connection refused, DNS failure, connection reset, connection closed mid-response, request body stream errors, ...), Deno put the low-level reqwest/hyper detail directly in the rejected error's `.message` and left `.cause` undefined. Node/undici instead reject with `TypeError: "fetch failed"` and surface the detail via `.cause`, which is the shape libraries branch on (e.g. checks for `err.message === "fetch failed"` / inspecting `err.cause`). Remap `ClientSend` errors in `op_fetch_send` to that shape. Permission and other typed errors keep their own type. The detail is still emitted to the inspector Network domain and OTel `exception.message`. Closes #35612
…test - cert::untrusted_cert_hint failed because the TLS hint matcher in fmt_errors.rs only inspects the top-level error message; the detail now lives in the cause of "TypeError: fetch failed". Fall back to the cause chain when the top-level message yields no suggestions. - serve_test's "Throw if disturbed"/"Throw if locked" asserted the raw transport error message on the client fetch; update to the new shape (message "fetch failed", detail in .cause).
Member
Author
|
CI failures addressed in a9d1559 (merged latest
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #35612
Problem
When the server closes the connection mid-response (or any other transport-level failure occurs), Deno rejected
fetchwith the raw reqwest/hyper detail directly in.messageand left.causeundefined:Node/undici instead reject with
TypeError: "fetch failed"and put the detail in.cause:Node-compatible error handling branches on this shape (
err.message === "fetch failed"/ inspectingerr.cause), so the divergence breaks libraries — surfaced while running the fastify suite underdeno test(fastify/fastify#6804).Change
op_fetch_sendnow remapsClientSendtransport errors (connection refused, DNS failure, connection reset, connection closed mid-response, request body stream errors, …) to Node's shape: aTypeErrorwhosemessageis"fetch failed"and whose.causecarries the low-level detail. Permission errors and other typed errors keep their own type. The detail is still emitted to the inspector Network domain (Network.loadingFailed.errorText) and to OpenTelemetry (exception.message).After the fix, the issue's reproduction matches Node:
Tests
fetchConnectionClosedBeforeMessageCompletemirroring the issue reproduction.otel_basic,fetch_async_error_stack) to assert the Node-compatible shape (detail moved from.messageto.cause).Note on scope
This covers the request/response phase (
"fetch failed"). A failure while reading the response body after headers are received is a separate Node shape (TypeError: "terminated") and is left for a follow-up.