Skip to content

Commit f0b0272

Browse files
authored
fetch items in DB on ReturnValuesOnConditionCheckFailure
1 parent e4968bf commit f0b0272

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/idempotency/src/persistence/DynamoDBPersistenceLayer.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { IdempotencyRecordStatus } from '../constants';
66
import type { DynamoDBPersistenceOptions } from '../types';
77
import {
88
AttributeValue,
9+
ConditionalCheckFailedException,
910
DeleteItemCommand,
1011
DynamoDBClient,
1112
DynamoDBClientConfig,
@@ -200,15 +201,13 @@ class DynamoDBPersistenceLayer extends BasePersistenceLayer {
200201
);
201202
} catch (error) {
202203
if (error instanceof DynamoDBServiceException) {
203-
if (error.name === 'ConditionalCheckFailedException') {
204+
if (error instanceof ConditionalCheckFailedException) {
204205
throw new IdempotencyItemAlreadyExistsError(
205-
`Failed to put record for already existing idempotency key: ${record.idempotencyKey}`
206+
`Failed to put record for already existing idempotency key: ${record.idempotencyKey}`,
207+
error.Item
206208
);
207209
}
208210
}
209-
210-
throw error;
211-
}
212211
}
213212

214213
protected async _updateRecord(record: IdempotencyRecord): Promise<void> {

0 commit comments

Comments
 (0)