Skip to content

Commit 2c8cf31

Browse files
committed
fix(api): ensure AbortError stops retry cycle and passes tests
1 parent 30a1dd2 commit 2c8cf31

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

frontend/lib/api/client.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,14 @@ function shouldRetryStatus(status: number): boolean {
4444
return status >= 500 || status === 429;
4545
}
4646

47+
// FIX: Robust check for AbortError to prevent test timeouts
4748
function shouldRetryError(error: unknown): boolean {
4849
if (error instanceof ApiError) {
4950
return shouldRetryStatus(error.status);
5051
}
5152

52-
if (
53-
(error instanceof Error && error.name === 'AbortError') ||
54-
(typeof error === 'object' &&
55-
error !== null &&
56-
'name' in error &&
57-
error.name === 'AbortError')
58-
) {
53+
const err = normalizeError(error);
54+
if (err.name === 'AbortError' || err.message.includes('aborted')) {
5955
return false;
6056
}
6157

@@ -141,7 +137,7 @@ export async function apiCall<T = unknown>(
141137
throw new OfflineActionQueuedError(
142138
'You are offline. This action has been queued and will sync when the connection returns.',
143139
endpoint,
144-
// @ts-expect-error - action.id may not be correctly typed in current SDK version
140+
// @ts-expect-error - action.id may not be correctly typed
145141
action.id
146142
);
147143
}

0 commit comments

Comments
 (0)