@claritylabs/cl-sdk 3.1.18 → 3.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application.js +6 -4
- package/dist/application.js.map +1 -1
- package/dist/application.mjs +6 -4
- package/dist/application.mjs.map +1 -1
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +53 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -93
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/application.mjs
CHANGED
|
@@ -111,17 +111,19 @@ function isRetryableError(error) {
|
|
|
111
111
|
}
|
|
112
112
|
return false;
|
|
113
113
|
}
|
|
114
|
-
async function withRetry(fn, log) {
|
|
114
|
+
async function withRetry(fn, log, options) {
|
|
115
|
+
const maxRetries = options?.maxRetries ?? MAX_RETRIES;
|
|
116
|
+
const baseDelayMs = options?.baseDelayMs ?? BASE_DELAY_MS;
|
|
115
117
|
for (let attempt = 0; ; attempt++) {
|
|
116
118
|
try {
|
|
117
119
|
return await fn();
|
|
118
120
|
} catch (error) {
|
|
119
|
-
if (!isRetryableError(error) || attempt >=
|
|
121
|
+
if (!isRetryableError(error) || attempt >= maxRetries) {
|
|
120
122
|
throw error;
|
|
121
123
|
}
|
|
122
124
|
const jitter = Math.random() * 1e3;
|
|
123
|
-
const delay =
|
|
124
|
-
await log?.(`Retryable error, retrying in ${(delay / 1e3).toFixed(1)}s (attempt ${attempt + 1}/${
|
|
125
|
+
const delay = baseDelayMs * Math.pow(2, attempt) + jitter;
|
|
126
|
+
await log?.(`Retryable error, retrying in ${(delay / 1e3).toFixed(1)}s (attempt ${attempt + 1}/${maxRetries})...`);
|
|
125
127
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
126
128
|
}
|
|
127
129
|
}
|