@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.js
CHANGED
|
@@ -178,17 +178,19 @@ function isRetryableError(error) {
|
|
|
178
178
|
}
|
|
179
179
|
return false;
|
|
180
180
|
}
|
|
181
|
-
async function withRetry(fn, log) {
|
|
181
|
+
async function withRetry(fn, log, options) {
|
|
182
|
+
const maxRetries = options?.maxRetries ?? MAX_RETRIES;
|
|
183
|
+
const baseDelayMs = options?.baseDelayMs ?? BASE_DELAY_MS;
|
|
182
184
|
for (let attempt = 0; ; attempt++) {
|
|
183
185
|
try {
|
|
184
186
|
return await fn();
|
|
185
187
|
} catch (error) {
|
|
186
|
-
if (!isRetryableError(error) || attempt >=
|
|
188
|
+
if (!isRetryableError(error) || attempt >= maxRetries) {
|
|
187
189
|
throw error;
|
|
188
190
|
}
|
|
189
191
|
const jitter = Math.random() * 1e3;
|
|
190
|
-
const delay =
|
|
191
|
-
await log?.(`Retryable error, retrying in ${(delay / 1e3).toFixed(1)}s (attempt ${attempt + 1}/${
|
|
192
|
+
const delay = baseDelayMs * Math.pow(2, attempt) + jitter;
|
|
193
|
+
await log?.(`Retryable error, retrying in ${(delay / 1e3).toFixed(1)}s (attempt ${attempt + 1}/${maxRetries})...`);
|
|
192
194
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
193
195
|
}
|
|
194
196
|
}
|