Skip to content

Commit 2da7c9e

Browse files
committed
chore: use setTimeout from node:timers
1 parent 5d8bd67 commit 2da7c9e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

packages/batch/tests/helpers/handlers.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { setTimeout } from 'node:timers/promises';
12
import type {
23
AttributeValue,
34
Context,
@@ -20,7 +21,7 @@ const asyncSqsRecordHandler = async (record: SQSRecord): Promise<string> => {
2021
if (body.includes('fail')) {
2122
throw new Error('Failed to process record.');
2223
}
23-
await new Promise((resolve) => setTimeout(resolve, 1));
24+
await setTimeout(1); // simulate some processing time
2425
return body;
2526
};
2627

@@ -40,7 +41,7 @@ const asyncKinesisRecordHandler = async (
4041
if (body.includes('fail')) {
4142
throw new Error('Failed to process record.');
4243
}
43-
await new Promise((resolve) => setTimeout(resolve, 1));
44+
await setTimeout(1); // simulate some processing time
4445
return body;
4546
};
4647

@@ -60,7 +61,7 @@ const asyncDynamodbRecordHandler = async (
6061
if (body.S?.includes('fail')) {
6162
throw new Error('Failed to process record.');
6263
}
63-
await new Promise((resolve) => setTimeout(resolve, 1));
64+
await setTimeout(1); // simulate some processing time
6465
return body;
6566
};
6667

@@ -91,7 +92,7 @@ const asyncHandlerWithContext = async (
9192
`Context possibly malformed. Displaying context:\n${context}`
9293
);
9394
}
94-
await new Promise((resolve) => setTimeout(resolve, 1));
95+
await setTimeout(1); // simulate some processing time
9596
return record.body;
9697
};
9798

0 commit comments

Comments
 (0)