Skip to content

Commit 208bf26

Browse files
committed
Fixed retry configuration to prevent test timeouts in failure threshold exceeded tests
- Replaced incorrect 'retry' property with proper 'retryStrategy' function - Limited retry attempts to 2 to prevent test timeouts (was previously using default 5 attempts) - Added 1-second delay between retry attempts for consistent timing - Tests now complete within 60-second timeout while maintaining correct behavior validation - Both map failure threshold exceeded count and percentage tests now pass reliably
1 parent 72858e7 commit 208bf26

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

packages/aws-durable-execution-sdk-js-examples/src/examples/map/failure-threshold-exceeded-count/map-failure-threshold-exceeded-count.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,23 @@ export const handler = withDurableExecution(
1717
"failure-threshold-items",
1818
items,
1919
async (ctx: DurableContext, item: number, index: number) => {
20-
return await ctx.step(`process-${index}`, async () => {
21-
if (item <= 3) {
22-
throw new Error(`Item ${item} failed`);
23-
}
24-
return item * 2;
25-
});
20+
return await ctx.step(
21+
`process-${index}`,
22+
async () => {
23+
if (item <= 3) {
24+
throw new Error(`Item ${item} failed`);
25+
}
26+
return item * 2;
27+
},
28+
{
29+
retryStrategy: (error: Error, attemptCount: number) => {
30+
if (attemptCount >= 2) {
31+
return { shouldRetry: false };
32+
}
33+
return { shouldRetry: true, delay: { seconds: 1 } };
34+
},
35+
},
36+
);
2637
},
2738
{
2839
completionConfig: {

packages/aws-durable-execution-sdk-js-examples/src/examples/map/failure-threshold-exceeded-percentage/map-failure-threshold-exceeded-percentage.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,23 @@ export const handler = withDurableExecution(
1818
"failure-threshold-items",
1919
items,
2020
async (ctx: DurableContext, item: number, index: number) => {
21-
return await ctx.step(`process-${index}`, async () => {
22-
if (item <= 3) {
23-
throw new Error(`Item ${item} failed`);
24-
}
25-
return item * 2;
26-
});
21+
return await ctx.step(
22+
`process-${index}`,
23+
async () => {
24+
if (item <= 3) {
25+
throw new Error(`Item ${item} failed`);
26+
}
27+
return item * 2;
28+
},
29+
{
30+
retryStrategy: (error: Error, attemptCount: number) => {
31+
if (attemptCount >= 2) {
32+
return { shouldRetry: false };
33+
}
34+
return { shouldRetry: true, delay: { seconds: 1 } };
35+
},
36+
},
37+
);
2738
},
2839
{
2940
completionConfig: {

0 commit comments

Comments
 (0)