Skip to content

Commit 0ab3d70

Browse files
committed
enable wait-for-callback timeout test
1 parent 8e38f1f commit 0ab3d70

File tree

3 files changed

+139
-10
lines changed

3 files changed

+139
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
[
2+
{
3+
"EventType": "ExecutionStarted",
4+
"EventId": 1,
5+
"Id": "a97f0be2-220c-4b7c-99c5-8fb9d3349d93",
6+
"EventTimestamp": "2025-12-12T00:23:39.528Z",
7+
"ExecutionStartedDetails": {
8+
"Input": {
9+
"Payload": "{\"timeoutSeconds\":1}"
10+
}
11+
}
12+
},
13+
{
14+
"EventType": "ContextStarted",
15+
"SubType": "WaitForCallback",
16+
"EventId": 2,
17+
"Id": "c4ca4238a0b92382",
18+
"Name": "my callback function",
19+
"EventTimestamp": "2025-12-12T00:23:39.533Z",
20+
"ContextStartedDetails": {}
21+
},
22+
{
23+
"EventType": "CallbackStarted",
24+
"SubType": "Callback",
25+
"EventId": 3,
26+
"Id": "ea66c06c1e1c05fa",
27+
"EventTimestamp": "2025-12-12T00:23:39.533Z",
28+
"ParentId": "c4ca4238a0b92382",
29+
"CallbackStartedDetails": {
30+
"CallbackId": "eyJleGVjdXRpb25JZCI6IjQ5Y2QzYjI5LTRhODYtNDQxZi1hNDRmLWNiZjBlZmJiNWEzNiIsIm9wZXJhdGlvbklkIjoiZWE2NmMwNmMxZTFjMDVmYSIsInRva2VuIjoiMmU5YTUwMWMtYmU1NS00ZjJlLTkzMjYtMjc4M2ZiYzhiYzcxIn0=",
31+
"Timeout": 1,
32+
"Input": {}
33+
}
34+
},
35+
{
36+
"EventType": "StepStarted",
37+
"SubType": "Step",
38+
"EventId": 4,
39+
"Id": "98c6f2c2287f4c73",
40+
"EventTimestamp": "2025-12-12T00:23:39.535Z",
41+
"ParentId": "c4ca4238a0b92382",
42+
"StepStartedDetails": {}
43+
},
44+
{
45+
"EventType": "StepSucceeded",
46+
"SubType": "Step",
47+
"EventId": 5,
48+
"Id": "98c6f2c2287f4c73",
49+
"EventTimestamp": "2025-12-12T00:23:39.535Z",
50+
"ParentId": "c4ca4238a0b92382",
51+
"StepSucceededDetails": {
52+
"Result": {},
53+
"RetryDetails": {}
54+
}
55+
},
56+
{
57+
"EventType": "InvocationCompleted",
58+
"EventId": 6,
59+
"EventTimestamp": "2025-12-12T00:23:39.537Z",
60+
"InvocationCompletedDetails": {
61+
"StartTimestamp": "2025-12-12T00:23:39.528Z",
62+
"EndTimestamp": "2025-12-12T00:23:39.537Z",
63+
"Error": {},
64+
"RequestId": "d83611bc-3327-49f0-9d78-08246956e0cb"
65+
}
66+
},
67+
{
68+
"EventType": "CallbackTimedOut",
69+
"SubType": "Callback",
70+
"EventId": 7,
71+
"Id": "ea66c06c1e1c05fa",
72+
"EventTimestamp": "2025-12-12T00:23:40.536Z",
73+
"ParentId": "c4ca4238a0b92382",
74+
"CallbackTimedOutDetails": {
75+
"Error": {
76+
"Payload": {
77+
"ErrorMessage": "Callback timed out"
78+
}
79+
}
80+
}
81+
},
82+
{
83+
"EventType": "ContextFailed",
84+
"SubType": "WaitForCallback",
85+
"EventId": 8,
86+
"Id": "c4ca4238a0b92382",
87+
"Name": "my callback function",
88+
"EventTimestamp": "2025-12-12T00:23:40.546Z",
89+
"ContextFailedDetails": {
90+
"Error": {
91+
"Payload": {
92+
"ErrorType": "CallbackError",
93+
"ErrorMessage": "Callback timed out"
94+
}
95+
}
96+
}
97+
},
98+
{
99+
"EventType": "InvocationCompleted",
100+
"EventId": 9,
101+
"EventTimestamp": "2025-12-12T00:23:40.547Z",
102+
"InvocationCompletedDetails": {
103+
"StartTimestamp": "2025-12-12T00:23:40.542Z",
104+
"EndTimestamp": "2025-12-12T00:23:40.547Z",
105+
"Error": {
106+
"Payload": {
107+
"ErrorType": "ChildContextError",
108+
"ErrorMessage": "Callback timed out"
109+
}
110+
},
111+
"RequestId": "0172677d-1faf-4949-a894-c5e96ee500eb"
112+
}
113+
},
114+
{
115+
"EventType": "ExecutionFailed",
116+
"EventId": 10,
117+
"Id": "a97f0be2-220c-4b7c-99c5-8fb9d3349d93",
118+
"EventTimestamp": "2025-12-12T00:23:40.547Z",
119+
"ExecutionFailedDetails": {
120+
"Error": {
121+
"Payload": {
122+
"ErrorType": "ChildContextError",
123+
"ErrorMessage": "Callback timed out"
124+
}
125+
}
126+
}
127+
}
128+
]

packages/aws-durable-execution-sdk-js-examples/src/examples/wait-for-callback/basic/wait-for-callback.test.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { createTests } from "../../../utils/test-helper";
88
createTests({
99
handler,
1010
invocationType: InvocationType.Event,
11-
tests: (runner, { isCloud, assertEventSignatures }) => {
11+
tests: (runner, { assertEventSignatures }) => {
1212
it("function completes when callback succeeds - happy case", async () => {
1313
const executionPromise = runner.run();
1414

@@ -37,15 +37,16 @@ createTests({
3737
assertEventSignatures(execution, "failure");
3838
});
3939

40-
// TODO: fix testing lib local runner time scaling to handle timeouts better
41-
if (isCloud) {
42-
it("function times out when callback is not called - failure case", async () => {
43-
const execution = await runner.run();
40+
it("function times out when callback is not called - failure case", async () => {
41+
const execution = await runner.run({
42+
payload: {
43+
timeoutSeconds: 1,
44+
},
45+
});
4446

45-
expect(execution.getError()).toBeDefined();
47+
expect(execution.getError()).toBeDefined();
4648

47-
assertEventSignatures(execution, "timed-out");
48-
});
49-
}
49+
assertEventSignatures(execution, "timed-out");
50+
});
5051
},
5152
});

packages/aws-durable-execution-sdk-js-examples/src/examples/wait-for-callback/basic/wait-for-callback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const handler = withDurableExecution(
2121
"my callback function",
2222
mySubmitterFunction,
2323
{
24-
timeout: { seconds: 5 },
24+
timeout: { seconds: event.timeoutSeconds ?? 5 },
2525
},
2626
);
2727
log("Hello world after callback!");

0 commit comments

Comments
 (0)