Skip to content

Commit 5ae6c3a

Browse files
simplify some retry logic
1 parent 49ae1e5 commit 5ae6c3a

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

sdk/src/network-client.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,14 +1451,6 @@ class AleoNetworkClient {
14511451
"Content-Type": "application/json",
14521452
}),
14531453
}),
1454-
{
1455-
// Only retry on network-level / transient errors to avoid duplicate submission
1456-
retryOnStatus: [500, 502, 503, 504],
1457-
shouldRetry: (err) => {
1458-
const msg = err?.message?.toLowerCase?.() || "";
1459-
return msg.includes("timeout") || msg.includes("network") || msg.includes("503");
1460-
},
1461-
}
14621454
);
14631455

14641456
try {

sdk/src/utils.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,15 @@ type RetryOptions = {
6161
return await fn();
6262
} catch (err: any) {
6363
const isLast = attempt === maxAttempts;
64-
6564
const error = err as Error & { code?: string; status?: number };
6665

67-
const retryable =
68-
(typeof error.status === "number" && retryOnStatus.includes(error.status)) ||
69-
error.message?.includes("5") ||
70-
error.message?.includes("404") ||
71-
shouldRetry?.(error);
66+
let retryable = false;
67+
68+
if (typeof error.status === "number") {
69+
retryable = retryOnStatus.includes(error.status);
70+
} else if (shouldRetry) {
71+
retryable = shouldRetry(error);
72+
}
7273

7374
if (!retryable || isLast) throw error;
7475

0 commit comments

Comments
 (0)