From 0afd20216474977e8baad027f00b30ea3ec63894 Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Sat, 11 Jul 2026 15:25:01 +0200 Subject: [PATCH] fix: let AbortError propagate through the API client The network-error wrapping added in the error-boundary work also caught deliberate AbortController cancellations and turned them into a network_error ApiError, breaking callers that distinguish "cancelled" from "failed" (the cancellable admin fetches). Rethrow DOMException AbortError unchanged; only genuine network failures become ApiError(status 0). Co-Authored-By: Claude Opus 4.8 (1M context) --- frontend/package.json | 2 +- frontend/src/lib/api/client.ts | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 0cdd7ff..8154c4c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "mangalord-frontend", - "version": "0.128.2", + "version": "0.128.3", "private": true, "type": "module", "scripts": { diff --git a/frontend/src/lib/api/client.ts b/frontend/src/lib/api/client.ts index 860a437..7fe5a30 100644 --- a/frontend/src/lib/api/client.ts +++ b/frontend/src/lib/api/client.ts @@ -106,12 +106,16 @@ export async function request( let res: Response; try { res = await fetch(`${BASE}${path}`, { credentials: 'include', ...init }); - } catch { - // A network-level failure (connection refused, DNS, offline, blocked by - // CORS) rejects `fetch` with a bare TypeError instead of returning a - // response. Normalise it to an ApiError (status 0 = "no response reached - // us") so callers and SvelteKit load functions handle it uniformly - // instead of crashing on an unexpected TypeError. + } catch (e) { + // A deliberate cancellation (AbortController) must propagate unchanged so + // callers can tell "cancelled" from "network failure" (e.g. the + // cancellable admin fetches treat AbortError as a no-op). + if (e instanceof DOMException && e.name === 'AbortError') throw e; + // Any other rejection is a network-level failure (connection refused, + // DNS, offline, blocked by CORS): `fetch` rejects with a bare TypeError + // instead of returning a response. Normalise it to an ApiError (status 0 + // = "no response reached us") so callers and SvelteKit load functions + // handle it uniformly instead of crashing on an unexpected TypeError. throw new ApiError( 0, 'network_error',