Home > @aws/durable-execution-sdk-js > DurableContext > waitForCallback
Wait for an external system to complete a callback with the SendDurableExecutionCallbackSuccess or SendDurableExecutionCallbackFailure APIs.
Signature:
waitForCallback<TOutput = string>(name: string | undefined, submitter: WaitForCallbackSubmitterFunc<TLogger>, config?: WaitForCallbackConfig<TOutput>): DurablePromise<TOutput>;|
Parameter |
Type |
Description |
|---|---|---|
|
name |
string | undefined |
Step name for tracking and debugging |
|
submitter |
WaitForCallbackSubmitterFunc<TLogger> |
Function that receives the callback ID and submits the callback |
|
config |
WaitForCallbackConfig<TOutput> |
(Optional) Optional configuration for timeout and retry behavior |
Returns:
DurablePromise<TOutput>
{CallbackError} When callback fails, times out, or external system reports failure
const result = await context.waitForCallback(
"wait-for-external-api",
async (callbackId, ctx) => {
// Submit callback ID to external system
await submitToExternalAPI(callbackId);
},
{ timeout: { minutes: 5 } },
);