How should waitForCallback be retried durably after callback failure or heartbeat timeout? #512
-
|
Hi, I am trying to understand the intended pattern for using ProblemI want to run an external async task through From reading the docs and SDK source, it looks like That means I currently need to write my own retry loop around Minimal exampleasync function runExternalTask(context: DurableContext): Promise<Result> {
let attempt = 0;
while (true) {
attempt += 1;
try {
return await context.waitForCallback<Result>(
"external-task",
async callbackId => {
await submitTaskToExternalSystem({ callbackId });
},
{
timeout: { minutes: 5 },
heartbeatTimeout: { seconds: 30 },
retryStrategy: (error, attemptCount) => ({
shouldRetry: attemptCount < 20,
delay: { seconds: 1 },
}),
},
);
} catch (error) {
if (!isRetryableCallbackError(error) || attempt >= 20) {
throw error;
}
await context.wait({ seconds: 1 });
}
}
}Question / feature requestIs there a recommended durable pattern for retrying Ideally, if the external system crashes after accepting the callback work, I would like the SDK to provide a way to retry the whole callback operation according to a retry policy, creating a new callback ID and re-running the submitter durably. The main thing I am looking for is a durable, SDK-supported way to express: "if the external worker fails or stops heartbeating, retry the external task according to this policy." |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hello, we are in the process of implementing the following feature which I believe would help with this use case: aws/aws-durable-execution-docs#140 (comment) In the problem statement, there is a pattern that you can use in the meantime. |
Beta Was this translation helpful? Give feedback.
Hello, we are in the process of implementing the following feature which I believe would help with this use case: aws/aws-durable-execution-docs#140 (comment)
In the problem statement, there is a pattern that you can use in the meantime.