Bug
When continue_as_new(..., save_events=True) carries buffered external events to the next execution, it groups them by event name instead of preserving their global arrival order.
Confirmed at commit ec9af14. microsoft/durabletask-go#163 preserves global ordering using arrival-order metadata; Python's equivalent path currently does not.
Reproduction
An orchestrator waits only on a timer, then continues as new with save_events=True. In the timer-completion batch, deliver events a:1, b:2, a:3, with no pending event waits.
Actual: carryover is a:1, a:3, b:2.
Expected: carryover is a:1, b:2, a:3, exactly once and in arrival order.
Relevant code and scope
durabletask/worker.py: _received_events is a dictionary of per-name payload lists; get_actions() iterates that dictionary to build carryoverEvents. Buffer consumption in wait_for_external_event() and new buffering in process_event() must remain consistent.
Maintain case-insensitive matching, FIFO consumption for each name, raw serialized payload preservation/custom converters, absent/null payload behavior, replay, cancellation, and save_events=False. Preserve only unconsumed buffered events, not ones already delivered to live waits.
This affects shared core execution used by Azure Managed and this repository's Azure Functions provider. Add focused regression coverage and applicable Unreleased changelog entries. The separate defect where abandoned losing waits consume trailing events should not be bundled into this fix.
Bug
When
continue_as_new(..., save_events=True)carries buffered external events to the next execution, it groups them by event name instead of preserving their global arrival order.Confirmed at commit ec9af14. microsoft/durabletask-go#163 preserves global ordering using arrival-order metadata; Python's equivalent path currently does not.
Reproduction
An orchestrator waits only on a timer, then continues as new with
save_events=True. In the timer-completion batch, deliver eventsa:1,b:2,a:3, with no pending event waits.Actual: carryover is
a:1,a:3,b:2.Expected: carryover is
a:1,b:2,a:3, exactly once and in arrival order.Relevant code and scope
durabletask/worker.py:_received_eventsis a dictionary of per-name payload lists;get_actions()iterates that dictionary to buildcarryoverEvents. Buffer consumption inwait_for_external_event()and new buffering inprocess_event()must remain consistent.Maintain case-insensitive matching, FIFO consumption for each name, raw serialized payload preservation/custom converters, absent/null payload behavior, replay, cancellation, and
save_events=False. Preserve only unconsumed buffered events, not ones already delivered to live waits.This affects shared core execution used by Azure Managed and this repository's Azure Functions provider. Add focused regression coverage and applicable Unreleased changelog entries. The separate defect where abandoned losing waits consume trailing events should not be bundled into this fix.