Skip to content

Breaking change in WaitForExternalEvent causes external events being dropped #508

Closed

Description

Description

  1. WaitForExternalEvent is called with a given event name and a cancellation token
  2. A cancellation request is sent using the cancellation token
  3. WaitForExternalEvent is called again with the same event name as the first call
  4. An event with that name is raised.

Expected behavior
The latest, non-cancelled WaitForExternalEvent call will consume the event

Actual behavior
The event will be routed to the first waiter, whose task was cancelled.

Findings
In the previous version of the Durable Task SDK, the task completion sources were stored in a stack (see DurableOrchestrationContext.cs line 897), so following the above description, the new WaitForExternalEvent call's waiter would consume the event in a LIFO pattern (see DurableOrchestrationContext.cs line 951.

In the new SDK, the waiters/task completion sources are stored in a queue (see TaskOrchestrationContextWrapper.cs line 303) and the calls are processed in a FIFO pattern. Even though the task is cancelled in step 2 (line 309), the task completion source is not removed from the queue. Since the incoming events are processed in a FIFO pattern, the event is assigned to the first task completion source, which has not been removed from the queue, and is effectively lost.

This same issue has also been described in Azure/azure-functions-durable-extension#3255.

This seems like an unintended breaking change, since WaitForExternalEvent now doesn't behave like the documentation suggests, when awaiting multiple events with the same name. I would greatly appreciate a fix for this issue, as it is blocker for migrating to the isolated worker model for my use case.

Activity

  1. github-actions commented on Mar 13, 2026

    @github-actions
    Contributor

    Issue Triage

    Classification: triage/already-fixed

    Reasoning:
    Closed. The WaitForExternalEvent breaking change causing dropped events has been addressed and is pending review.

    Automated fix candidate: No

    • Issue is already closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions