Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds the ability to retrieve orchestration execution history through a new getOrchestrationHistory API method. The PR introduces comprehensive type definitions for all history event types, implements conversion from protobuf messages to TypeScript objects, and includes extensive E2E test coverage.
Changes:
- Added
getOrchestrationHistorymethod toTaskHubGrpcClientfor retrieving instance execution history - Introduced
StartOrchestrationOptionsinterface to support passing tags and other metadata when scheduling orchestrations - Created comprehensive type definitions for 26+ history event types covering orchestration lifecycle, activities, timers, sub-orchestrations, external events, and entities
- Implemented protobuf-to-TypeScript conversion logic for all history event types
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/durabletask-js/src/orchestration/history-event.ts | Defines TypeScript interfaces for all history event types including ExecutionStarted, TaskScheduled, TimerCreated, etc. |
| packages/durabletask-js/src/utils/history-event-converter.ts | Implements conversion from protobuf HistoryEvent messages to TypeScript HistoryEvent objects |
| packages/durabletask-js/src/client/client.ts | Adds getOrchestrationHistory method and extends scheduleNewOrchestration to support tags via StartOrchestrationOptions |
| packages/durabletask-js/src/index.ts | Exports history event types and StartOrchestrationOptions for public API consumption |
| test/e2e-azuremanaged/history.spec.ts | Comprehensive E2E tests validating history retrieval for various orchestration patterns including activities, timers, sub-orchestrations, and external events |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…letask-js into wangbill/history
torosent
left a comment
There was a problem hiding this comment.
1. Inconsistent error handling for NOT_FOUND
Location: client.ts#L836-L845
The implementation throws an error when an orchestration is not found:
if (err.code === grpc.status.NOT_FOUND) {
reject(new Error(`An orchestration with the instanceId '${instanceId}' was not found.`));
}However, the E2E test expects an empty array:
// test/e2e-azuremanaged/history.spec.ts:267-270
it("should return empty array for non-existent orchestration", async () => {
const history = await taskHubClient.getOrchestrationHistory("non-existent-instance-id");
expect(history).toEqual([]);
});Recommendation: Either fix the test to expect an error, or change the implementation to return an empty array for NOT_FOUND (which is more user-friendly and consistent with other SDKs).
2. Missing unit tests for convertProtoHistoryEvent
Location: history-event-converter.ts
The converter utility is ~300 lines with a complex switch statement covering 25+ event types. There are no unit tests for it—only E2E tests exist.
Impact: Edge cases where protobuf fields are missing/undefined may not be caught.
Recommendation: Add unit tests covering:
- Each event type conversion
- Missing optional fields
- Null/undefined handling
- Invalid event type case (default branch)
…existent instances and update documentation for clarity
Summary
What changed?
getOrchestrationHistory(instanceId: string)method toTaskHubGrpcClientthat retrieves the complete history of an orchestration instance as an array of typedHistoryEventobjectsExecutionStartedEvent,TaskScheduledEvent,TaskCompletedEvent,TimerCreatedEvent,SubOrchestrationInstanceCreated, etc.)TraceContextandParentInstanceInfotypes for distributed tracing and sub-orchestration supportWhy is this change needed?
GetOrchestrationHistoryAsyncmethodIssues / work items
Project checklist
CHANGELOG.mdAI-assisted code disclosure (required)
Was an AI tool used? (select one)
If AI was used:
packages/durabletask-js/src/orchestration/history-event.ts- Type definitions for all history eventspackages/durabletask-js/src/utils/history-event-converter.ts- Proto to TS conversion logicpackages/durabletask-js/src/client/client.ts-getOrchestrationHistorymethod implementationtest/e2e-azuremanaged/history.spec.ts- Comprehensive E2E testsAI verification (required if AI was used):
Testing
Automated tests
test/e2e-azuremanaged/history.spec.tscovering:Manual validation (only if runtime/behavior changed)
npx jest test/e2e-azuremanaged/history.spec.ts --runInBand --forceExitNotes for reviewers
PartitionGrain.ClientOperations.cs. The implementation includes NOT_FOUND error handling for future-proofing.removeAllListeners()to prevent memory leaks.OrchestrationStatusenum from protobuf doesn't have a reverse mapping, so an explicitORCHESTRATION_STATUS_MAPis used for conversion.