Skip to content

fix: split fetch network errors from unreachable server failures - #96

Merged
mhweiner merged 6 commits into
mainfrom
fix/split-fetch-network-vs-server-errors
Aug 27, 2026
Merged

fix: split fetch network errors from unreachable server failures#96
mhweiner merged 6 commits into
mainfrom
fix/split-fetch-network-vs-server-errors

Conversation

@logfox-agent

@logfox-agent logfox-agent commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

What was going wrong

When fetch throws before any HTTP response, the client always returned NETWORK_ERROR (status 0). That mixed “device offline” with “API unreachable while online,” so frontends showed “check your connection” when the server was down.

What this PR changes

Two rules in CallspecClient.callResult when fetch throws:

Situation Code Status
navigator.onLine === false, or request aborted NETWORK_ERROR 0
Everything else SERVICE_UNAVAILABLE 503

No message parsing or cause-chain heuristics — browsers already throw the same Failed to fetch for both cases, so we only split on offline vs not.

HTTP response normalization is unchanged.

Breaking change

Online + unreachable API now returns SERVICE_UNAVAILABLE instead of NETWORK_ERROR. App frontends that map SERVICE_UNAVAILABLEServiceBusy get the right UX without extra work.

Test plan

  • npm run validate
  • After release: bump callspec in app-frontend

skyy and others added 6 commits August 26, 2026 21:19
When fetch throws before any HTTP response, classify offline/abort as
NETWORK_ERROR and unreachable API hosts while online as INTERNAL_ERROR
(status 500) with diagnostic data for logging.

Co-authored-by: Cursor <cursoragent@cursor.com>
Connection refused and online Failed to fetch are service reachability
failures (503), not unhandled handler bugs (500).

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Inline offline vs online handling in CallspecClient instead of a separate
classifyFetchFailure module with regex heuristics.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Tests pass isOnline like fetch; production default still reads navigator.onLine.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mhweiner
mhweiner merged commit 265f80b into main Aug 27, 2026
3 checks passed
@mhweiner
mhweiner deleted the fix/split-fetch-network-vs-server-errors branch August 27, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants