Skip to content

Correct Cloudflare network error detection - #13

Closed
timkelty wants to merge 1 commit into
sindresorhus:mainfrom
timkelty:fix-cloudflare-network-errors
Closed

Correct Cloudflare network error detection#13
timkelty wants to merge 1 commit into
sindresorhus:mainfrom
timkelty:fix-cloudflare-network-errors

Conversation

@timkelty

@timkelty timkelty commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

PR #10 copied Cloudflare's unpunctuated documentation label into the existing TypeError message set. Workerd instead constructs Error("Network connection lost.") for disconnections.

This replaces the mistaken matcher with the actual runtime shape and updates the type guard to Error.

Workerd source · Workerd test

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T17:17:54.597189Z 74dbb3d Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@timkelty
timkelty marked this pull request as draft August 29, 2026 16:52
@timkelty
timkelty force-pushed the fix-cloudflare-network-errors branch from b3a6ea4 to 1fbad30 Compare August 29, 2026 16:56
@timkelty
timkelty marked this pull request as ready for review August 29, 2026 16:57
@timkelty
timkelty force-pushed the fix-cloudflare-network-errors branch 2 times, most recently from c6b093b to de6d605 Compare August 29, 2026 17:04
@timkelty
timkelty marked this pull request as draft August 29, 2026 17:04
@timkelty timkelty changed the title Fix Cloudflare network error detection Aug 29, 2026
@timkelty
timkelty force-pushed the fix-cloudflare-network-errors branch 2 times, most recently from 9e53889 to 38d2ff7 Compare August 29, 2026 17:08
@timkelty
timkelty force-pushed the fix-cloudflare-network-errors branch from 38d2ff7 to 74dbb3d Compare August 29, 2026 17:12
@timkelty
timkelty marked this pull request as ready for review August 29, 2026 17:15
@sindresorhus

Copy link
Copy Markdown
Owner

This error appears to be Workerd’s generic representation for any DISCONNECTED exception, not something specific to Fetch. That means we cannot reliably distinguish a Fetch network error from binding, socket, stream, or Durable Object failures.

The Fetch standard requires network failures to reject with a TypeError, so I think the correct fix belongs in Workerd rather than broadening this package’s contract based on a generic error message.

@timkelty

timkelty commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Fair enough. I'll post an update here when I open one in workerd.

@timkelty

timkelty commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Opened cloudflare/workerd#7195 with a current workerd repro and the Fetch spec requirement: cloudflare/workerd#7195

FWIW - with this realization, you might consider removing the current CF workers check for clarity. Even if workerd starts throwing TypeError, it looks like the check is missing the trailing . and wouldn't match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants