fix: handle EventSent replay events#264
Merged
Merged
Conversation
The orchestration executor's processEvent switch statement was missing a case for the EVENTSENT history event type. When an orchestrator calls ctx.sendEvent(), the sidecar records an EventSentEvent to confirm the action was processed. Without handling this event during replay, the sendEvent action remained in _pendingActions and was returned to the sidecar again via getActions(), potentially causing duplicate event delivery. This adds a handleEventSent method that validates and removes the sendEvent action from _pendingActions on replay, consistent with how handleTaskScheduled, handleTimerCreated, and handleSubOrchestrationCreated handle their respective confirmation events. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
80018f5 to
367f7d4
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Durable Task JS orchestration executor to correctly handle EventSent replay history events, preventing duplicate sendEvent actions from being returned during replay (fixing the missing EVENTSENT handler described in issue #241).
Changes:
- Add
EVENTSENThandling inOrchestrationExecutor.processEventand implementhandleEventSentto remove the corresponding pendingsendEventaction. - Add executor tests covering correct replay behavior and non-determinism scenarios for
EVENTSENT. - Add a protobuf test helper
newEventSentEvent(...)for constructingEventSenthistory events in tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/durabletask-js/src/worker/orchestration-executor.ts | Adds EVENTSENT switch case and handleEventSent logic to clear pending sendEvent actions during replay. |
| packages/durabletask-js/test/orchestration_executor.spec.ts | Adds a dedicated test suite validating replay behavior and failure modes for EVENTSENT. |
| packages/durabletask-js/src/utils/pb-helper.util.ts | Adds newEventSentEvent(...) helper for constructing EventSent history events in tests. |
Validate sendEvent names when replaying EventSent history and throw a focused NonDeterminismError for wrong action types without relying on getMethodNameForAction. Update tests to use registered activity names and cover mismatched event names. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Validate EventSent target instance IDs before removing replayed sendEvent actions from pending actions. Move pending-action cleanup after replay validation succeeds and add regression coverage for target mismatch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
kaibocai
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #241