Skip to content

GetActivityTask

Source: src/AWS/StepFunctions/GetActivityTask.ts

Runtime binding for states:GetActivityTask — the activity worker’s long-poll. Bind this operation to an Activity inside a function runtime to receive scheduled activity tasks with the activity ARN injected automatically.

The call blocks for up to 60 seconds when no task is scheduled (an empty taskToken means the poll timed out) — size the host’s timeout accordingly. Complete the returned task with SendTaskSuccess / SendTaskFailure, keeping it alive with SendTaskHeartbeat.

const getActivityTask = yield* StepFunctions.GetActivityTask(activity);
const sendTaskSuccess = yield* StepFunctions.SendTaskSuccess(activity);
const task = yield* getActivityTask({ workerName: "worker-1" });
if (task.taskToken) {
yield* sendTaskSuccess({
taskToken: task.taskToken,
output: JSON.stringify({ handled: true }),
});
}