dapr / dapr/js-sdk

feat(workflows) Support task execution IDs

Open
#802 0 comments 0 reactions 0 assignees View on GitHub
area/workflow enhancement sdk-parity
Dominant language
JavaScript
Stars
217
Forks
104
PR merge metrics
No merged PRs in 30d

Description

## Summary

Implement support for task execution IDs in the Dapr JS SDK Workflow implementation, enabling unique identification of individual task executions within a workflow instance.

## Background

When a workflow schedules a task (activity, timer, sub-workflow, external event wait), it currently identifies that task by its sequence number in the orchestration history. Task execution IDs provide a richer identification mechanism that:

- Uniquely identifies each task execution across the lifetime of a workflow instance
- Enables more precise correlation of completions to scheduled tasks
- Supports advanced scenarios like task cancellation, status queries on individual tasks, and exactly-once delivery guarantees
- Provides better observability and debugging (trace individual task executions)

See the [Dapr proposal](https://github.com/dapr/proposals/pull/85) for the full design and motivation.

## Proposed Changes

1. **Generate execution IDs** when scheduling tasks via `WorkflowContext` - check this: I think they might be created by the runtime, meaning we can skip this step in the implementation
2. **Expose execution IDs** on the `Task` objects returned by `callActivity`, `callSubWorkflow`, `createTimer`, `waitForExternalEvent`
3. **Use execution IDs for correlation** when matching completion events to pending tasks during replay
4. **Surface execution IDs in `DaprWorkflowClient`** for task-level status queries (if supported by the API)

## Proposed API

```typescript
function* myWorkflow(ctx: WorkflowContext, input: any) {
const task = ctx.callActivity(processData, input);

// Access the execution ID for logging/correlation
console.log(`Scheduled activity with execution ID: ${task.executionId}`);

const result = yield task;
return result;
}
```

## Acceptance Criteria
- [ ] Task execution IDs are generated and included in scheduled task messages
- [ ] Task objects expose an `executionId` property
- [ ] Completion correlation uses execution IDs where available
- [ ] Backward compatibility is maintained (instances started without execution IDs continue to work)
- [ ] Unit tests verify execution ID generation and correlation
- [ ] Integration tests verify task execution IDs flow through the system

## References
[Dapr Proposal: Task Execution IDs](https://github.com/dapr/proposals/pull/85)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.