microsoft / microsoft/durabletask-dotnet

Listening for same event recurringly does not resolve latest non-canceled task

Open
#147 10 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

breaking change bug
Dominant language
C#
Stars
193
Forks
60
Avg merge
3d 12h
Merged PRs (30d)
4

Description

The docs of TaskOrchestrationContext.WaitForExternalEvent state:

Orchestrators can wait for the same event name multiple times, so waiting for multiple events with the same name is allowed. Each external event received by an orchestrator will complete just one task returned by this method.

However, when cancelling an earlier listener task before any event with that name has arrived, a later listener task won't be resolved by the next arriving event.

I've created a minimal reproduction in this repository, specifically inside MyOrchestration.cs where a listener for event name "RecurringEvent" is registered three times while only one listener is active (meaning not-cancelled) at a time and only the last listener is meant to resolve.

After starting the orchestrator via http://localhost:7071/api/MyOrchestration_HttpStart, I'd expect the following steps to result in its completion:

  1. Raise event "OneTimeEvent1"
  2. Raise event "OneTimeEvent2"
  3. Raise event "RecurringEvent"

Instead, the orchestrator only completes after sending "RecurringEvent" one more time:

  1. Raise event "OneTimeEvent1"
  2. Raise event "OneTimeEvent2"
  3. Raise event "RecurringEvent"
  4. Raise event "RecurringEvent"

At first I thought the runtime might serve earlier listeners even though they're canceled, however, this does not seem to be exactly the case since I'm registering three listeners while its sufficient to send the corresponding event only two times.

System Info

  • MacBook Pro M1 Ventura 13.2.1 / Windows 10 on Desktop PC
  • Azurite for Storage Emulation

Workaround

I've refactored code that relied on this pattern to hold a reference to a single listener instead of cancelling earlier listeners and starting new ones.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked MyOrchestration.cs reproduction and the TaskOrchestrationContext.WaitForExternalEvent entry point. Reproduce the cancellation sequence using the documented HTTP start and event steps, then trace how canceled and recurring listeners are matched. Done means one RecurringEvent resolves the latest non-canceled listener after the earlier listeners are canceled.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.