From ffea1ce0298c9acf1d7a3f6eb5c926dc5e3decd1 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Fri, 19 Jan 2024 14:40:06 -0800 Subject: [PATCH] fix: deduplicate order notifications --- lib/repositories/orders-repository.ts | 3 +++ test/repositories/dynamo-repository.test.ts | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/repositories/orders-repository.ts b/lib/repositories/orders-repository.ts index 22b2ddf4..6072a5cf 100644 --- a/lib/repositories/orders-repository.ts +++ b/lib/repositories/orders-repository.ts @@ -106,6 +106,9 @@ export class DynamoOrdersRepository implements BaseOrdersRepository { txHash: { type: DYNAMODB_TYPES.STRING }, settledAmounts: { type: DYNAMODB_TYPES.LIST }, }, + // Timestamps are explicitly turned off to avoid re-triggering dynamo streams, + // which can happen when only the modified timestamp is updated (by a Put/Update). + timestamps: false, table: ordersTable, } as const) diff --git a/test/repositories/dynamo-repository.test.ts b/test/repositories/dynamo-repository.test.ts index f1cc64c6..2516938f 100644 --- a/test/repositories/dynamo-repository.test.ts +++ b/test/repositories/dynamo-repository.test.ts @@ -460,7 +460,6 @@ describe('OrdersRepository getOrders test with sorting', () => { describe('OrdersRepository getByHash test', () => { it('should successfully get an item from table', async () => { const order1 = await ordersRepository.getByHash(MOCK_ORDER_1.orderHash) - // dynamodb-toolbox auto-generates 'created' and 'modified' fields expect(order1).toEqual(expect.objectContaining(MOCK_ORDER_1)) const order2 = await ordersRepository.getByHash(MOCK_ORDER_2.orderHash)