@upyo/retry 0.5.0-dev.199 → 0.5.0-dev.201
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/index.cjs +23 -12
- package/dist/index.js +23 -12
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -187,6 +187,7 @@ var RetryTransport = class {
|
|
|
187
187
|
let launchPromise;
|
|
188
188
|
let launchError;
|
|
189
189
|
let hasLaunchError = false;
|
|
190
|
+
let hasQueuedFailure = false;
|
|
190
191
|
let pullingInput = false;
|
|
191
192
|
let closed = false;
|
|
192
193
|
const controller = new AbortController();
|
|
@@ -229,7 +230,7 @@ var RetryTransport = class {
|
|
|
229
230
|
inFlight.set(index, promise);
|
|
230
231
|
};
|
|
231
232
|
const startLaunch = () => {
|
|
232
|
-
if (launchPromise != null || inputDone || hasLaunchError || inFlight.size >= this.config.sendMany.maxConcurrent) return;
|
|
233
|
+
if (launchPromise != null || inputDone || hasLaunchError || hasQueuedFailure || inFlight.size >= this.config.sendMany.maxConcurrent) return;
|
|
233
234
|
launchPromise = launchNext().catch((error) => {
|
|
234
235
|
launchError = error;
|
|
235
236
|
hasLaunchError = true;
|
|
@@ -257,6 +258,7 @@ var RetryTransport = class {
|
|
|
257
258
|
if ("launched" in result) continue;
|
|
258
259
|
inFlight.delete(result.index);
|
|
259
260
|
completed.set(result.index, result);
|
|
261
|
+
if (!result.successful) hasQueuedFailure = true;
|
|
260
262
|
startLaunch();
|
|
261
263
|
}
|
|
262
264
|
if (hasLaunchError) throw launchError;
|
|
@@ -282,15 +284,20 @@ var RetryTransport = class {
|
|
|
282
284
|
* @since 0.5.0
|
|
283
285
|
*/
|
|
284
286
|
async [Symbol.asyncDispose]() {
|
|
285
|
-
const
|
|
286
|
-
const
|
|
287
|
-
if (typeof
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
const wrappedTransport = Object(this.wrappedTransport);
|
|
288
|
+
const asyncDisposeSymbol = Symbol.asyncDispose;
|
|
289
|
+
if (typeof asyncDisposeSymbol === "symbol") {
|
|
290
|
+
const asyncDispose = wrappedTransport[asyncDisposeSymbol];
|
|
291
|
+
if (typeof asyncDispose === "function") {
|
|
292
|
+
await asyncDispose.call(wrappedTransport);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
const disposeSymbol = Symbol.dispose;
|
|
297
|
+
if (typeof disposeSymbol === "symbol") {
|
|
298
|
+
const dispose = wrappedTransport[disposeSymbol];
|
|
299
|
+
if (typeof dispose === "function") dispose.call(wrappedTransport);
|
|
290
300
|
}
|
|
291
|
-
const disposable = this.wrappedTransport;
|
|
292
|
-
const dispose = disposable[Symbol.dispose];
|
|
293
|
-
if (typeof dispose === "function") dispose.call(disposable);
|
|
294
301
|
}
|
|
295
302
|
withSuccessMetadata(receipt, attempts) {
|
|
296
303
|
return {
|
|
@@ -397,7 +404,8 @@ function getRetryAfterMilliseconds(failure) {
|
|
|
397
404
|
return failure.errors?.find((error) => error.retryAfterMilliseconds != null)?.retryAfterMilliseconds;
|
|
398
405
|
}
|
|
399
406
|
function toAsyncIterator(values) {
|
|
400
|
-
|
|
407
|
+
const asyncIterator = values[Symbol.asyncIterator];
|
|
408
|
+
if (typeof asyncIterator === "function") return asyncIterator.call(values);
|
|
401
409
|
const iterator = values[Symbol.iterator]();
|
|
402
410
|
return {
|
|
403
411
|
async next() {
|
|
@@ -412,11 +420,11 @@ function toAsyncIterator(values) {
|
|
|
412
420
|
};
|
|
413
421
|
}
|
|
414
422
|
function raceWithAbort(promise, signal) {
|
|
415
|
-
if (signal.aborted) return Promise.reject(signal
|
|
423
|
+
if (signal.aborted) return Promise.reject(getAbortReason(signal));
|
|
416
424
|
return new Promise((resolve, reject) => {
|
|
417
425
|
const abort = () => {
|
|
418
426
|
cleanup();
|
|
419
|
-
reject(signal
|
|
427
|
+
reject(getAbortReason(signal));
|
|
420
428
|
};
|
|
421
429
|
const cleanup = () => {
|
|
422
430
|
signal.removeEventListener("abort", abort);
|
|
@@ -431,6 +439,9 @@ function raceWithAbort(promise, signal) {
|
|
|
431
439
|
});
|
|
432
440
|
});
|
|
433
441
|
}
|
|
442
|
+
function getAbortReason(signal) {
|
|
443
|
+
return signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
444
|
+
}
|
|
434
445
|
function toReceiptError(value) {
|
|
435
446
|
return isReceiptError(value) ? value : void 0;
|
|
436
447
|
}
|
package/dist/index.js
CHANGED
|
@@ -164,6 +164,7 @@ var RetryTransport = class {
|
|
|
164
164
|
let launchPromise;
|
|
165
165
|
let launchError;
|
|
166
166
|
let hasLaunchError = false;
|
|
167
|
+
let hasQueuedFailure = false;
|
|
167
168
|
let pullingInput = false;
|
|
168
169
|
let closed = false;
|
|
169
170
|
const controller = new AbortController();
|
|
@@ -206,7 +207,7 @@ var RetryTransport = class {
|
|
|
206
207
|
inFlight.set(index, promise);
|
|
207
208
|
};
|
|
208
209
|
const startLaunch = () => {
|
|
209
|
-
if (launchPromise != null || inputDone || hasLaunchError || inFlight.size >= this.config.sendMany.maxConcurrent) return;
|
|
210
|
+
if (launchPromise != null || inputDone || hasLaunchError || hasQueuedFailure || inFlight.size >= this.config.sendMany.maxConcurrent) return;
|
|
210
211
|
launchPromise = launchNext().catch((error) => {
|
|
211
212
|
launchError = error;
|
|
212
213
|
hasLaunchError = true;
|
|
@@ -234,6 +235,7 @@ var RetryTransport = class {
|
|
|
234
235
|
if ("launched" in result) continue;
|
|
235
236
|
inFlight.delete(result.index);
|
|
236
237
|
completed.set(result.index, result);
|
|
238
|
+
if (!result.successful) hasQueuedFailure = true;
|
|
237
239
|
startLaunch();
|
|
238
240
|
}
|
|
239
241
|
if (hasLaunchError) throw launchError;
|
|
@@ -259,15 +261,20 @@ var RetryTransport = class {
|
|
|
259
261
|
* @since 0.5.0
|
|
260
262
|
*/
|
|
261
263
|
async [Symbol.asyncDispose]() {
|
|
262
|
-
const
|
|
263
|
-
const
|
|
264
|
-
if (typeof
|
|
265
|
-
|
|
266
|
-
|
|
264
|
+
const wrappedTransport = Object(this.wrappedTransport);
|
|
265
|
+
const asyncDisposeSymbol = Symbol.asyncDispose;
|
|
266
|
+
if (typeof asyncDisposeSymbol === "symbol") {
|
|
267
|
+
const asyncDispose = wrappedTransport[asyncDisposeSymbol];
|
|
268
|
+
if (typeof asyncDispose === "function") {
|
|
269
|
+
await asyncDispose.call(wrappedTransport);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const disposeSymbol = Symbol.dispose;
|
|
274
|
+
if (typeof disposeSymbol === "symbol") {
|
|
275
|
+
const dispose = wrappedTransport[disposeSymbol];
|
|
276
|
+
if (typeof dispose === "function") dispose.call(wrappedTransport);
|
|
267
277
|
}
|
|
268
|
-
const disposable = this.wrappedTransport;
|
|
269
|
-
const dispose = disposable[Symbol.dispose];
|
|
270
|
-
if (typeof dispose === "function") dispose.call(disposable);
|
|
271
278
|
}
|
|
272
279
|
withSuccessMetadata(receipt, attempts) {
|
|
273
280
|
return {
|
|
@@ -374,7 +381,8 @@ function getRetryAfterMilliseconds(failure) {
|
|
|
374
381
|
return failure.errors?.find((error) => error.retryAfterMilliseconds != null)?.retryAfterMilliseconds;
|
|
375
382
|
}
|
|
376
383
|
function toAsyncIterator(values) {
|
|
377
|
-
|
|
384
|
+
const asyncIterator = values[Symbol.asyncIterator];
|
|
385
|
+
if (typeof asyncIterator === "function") return asyncIterator.call(values);
|
|
378
386
|
const iterator = values[Symbol.iterator]();
|
|
379
387
|
return {
|
|
380
388
|
async next() {
|
|
@@ -389,11 +397,11 @@ function toAsyncIterator(values) {
|
|
|
389
397
|
};
|
|
390
398
|
}
|
|
391
399
|
function raceWithAbort(promise, signal) {
|
|
392
|
-
if (signal.aborted) return Promise.reject(signal
|
|
400
|
+
if (signal.aborted) return Promise.reject(getAbortReason(signal));
|
|
393
401
|
return new Promise((resolve, reject) => {
|
|
394
402
|
const abort = () => {
|
|
395
403
|
cleanup();
|
|
396
|
-
reject(signal
|
|
404
|
+
reject(getAbortReason(signal));
|
|
397
405
|
};
|
|
398
406
|
const cleanup = () => {
|
|
399
407
|
signal.removeEventListener("abort", abort);
|
|
@@ -408,6 +416,9 @@ function raceWithAbort(promise, signal) {
|
|
|
408
416
|
});
|
|
409
417
|
});
|
|
410
418
|
}
|
|
419
|
+
function getAbortReason(signal) {
|
|
420
|
+
return signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
421
|
+
}
|
|
411
422
|
function toReceiptError(value) {
|
|
412
423
|
return isReceiptError(value) ? value : void 0;
|
|
413
424
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upyo/retry",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.201",
|
|
4
4
|
"description": "Retry and backoff decorator transport for Upyo email library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"sideEffects": false,
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@upyo/core": "0.5.0-dev.
|
|
57
|
+
"@upyo/core": "0.5.0-dev.201+ecb7233a"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"tsdown": "^0.12.7",
|