Skip to content

Commit 783c3d8

Browse files
committed
fix(idempotency): check error identity via names
1 parent 82b1f85 commit 783c3d8

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/idempotency/src/IdempotencyHandler.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,11 @@ export class IdempotencyHandler<Func extends AnyFunction> {
346346

347347
return returnValue;
348348
} catch (e) {
349+
/* if (!(e instanceof Error)) throw e;
350+
if (e.name === 'IdempotencyItemAlreadyExistsError') { */
349351
if (e instanceof IdempotencyItemAlreadyExistsError) {
350-
let idempotencyRecord = e.existingRecord;
352+
let idempotencyRecord = (e as IdempotencyItemAlreadyExistsError)
353+
.existingRecord;
351354
if (idempotencyRecord !== undefined) {
352355
// If the error includes the existing record, we can use it to validate
353356
// the record being processed and cache it in memory.

packages/idempotency/src/errors.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class IdempotencyItemAlreadyExistsError extends Error {
88

99
public constructor(message?: string, existingRecord?: IdempotencyRecord) {
1010
super(message);
11+
this.name = 'IdempotencyItemAlreadyExistsError';
1112
this.existingRecord = existingRecord;
1213
}
1314
}

0 commit comments

Comments
 (0)