Skip to content

fix: handle EventSent replay events#264

Merged
YunchuWang merged 3 commits into
mainfrom
copilot-finds/bug/missing-eventsent-handler
Jun 12, 2026
Merged

fix: handle EventSent replay events#264
YunchuWang merged 3 commits into
mainfrom
copilot-finds/bug/missing-eventsent-handler

Conversation

@YunchuWang

Copy link
Copy Markdown
Member

Summary

Fixes #241

Copilot AI review requested due to automatic review settings June 11, 2026 20:53
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>
@YunchuWang YunchuWang force-pushed the copilot-finds/bug/missing-eventsent-handler branch from 80018f5 to 367f7d4 Compare June 11, 2026 20:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 EVENTSENT handling in OrchestrationExecutor.processEvent and implement handleEventSent to remove the corresponding pending sendEvent action.
  • Add executor tests covering correct replay behavior and non-determinism scenarios for EVENTSENT.
  • Add a protobuf test helper newEventSentEvent(...) for constructing EventSent history 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.

Comment thread packages/durabletask-js/src/worker/orchestration-executor.ts
Comment thread packages/durabletask-js/src/worker/orchestration-executor.ts
Comment thread packages/durabletask-js/test/orchestration_executor.spec.ts
Comment thread packages/durabletask-js/test/orchestration_executor.spec.ts
YunchuWang and others added 2 commits June 12, 2026 09:22
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>
@YunchuWang YunchuWang merged commit 51776da into main Jun 12, 2026
28 checks passed
@YunchuWang YunchuWang deleted the copilot-finds/bug/missing-eventsent-handler branch June 12, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[copilot-finds] Bug: Orchestration executor missing EVENTSENT handler causes duplicate sendEvent actions on replay

4 participants