Reject fetch() with the cause when the connection can't be made #8653
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 242 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.329
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8653"
general
weight: 0.35
littledivy
In workerd serve and local dev, fetch() to a host that doesn't resolve, or to a server whose certificate isn't trusted, rejects with an internal error that says nothing about what went wrong:
The outbound client, kj-hyper, turns the failed DNS lookup or TLS handshake into a FAILED kj exception with the I/O error as its description, which JavaScript only sees as an internal error. A refused connection is DISCONNECTED and already rejects with "Network connection lost.".
In this patch kj-hyper marks its failures with
kj::Exceptiondetails instead of leaving fetch() to match their text:INVALID_RESPONSE_DETAIL_IDdetail with the reason as its payload. fetch() reads the reason from it, so the message JavaScript sees doesn't change. kj's own HttpClient sets no detail, so fetch() still recognises its descriptions as before.CONNECT_FAILED_DETAIL_IDdetail with the cause as its payload. DISCONNECTED and OVERLOADED connect failures keep their type and message.fetch_invalid_response_type_errorit rejects with a TypeError, like a response head that doesn't parse; without the flag it rejects with an Error. The flag has no enable date yet, and its documentation now covers this case too.fetch-invalid-response-test checks a host that doesn't resolve and a TLS server with a self-signed certificate under both flags. The kj-hyper tests check both details, and that a refused connection stays DISCONNECTED without one.
Fixes #8574