Repository navigation
fix: answer callers queued behind a macrostep that raises - #688
Merged
Merged
Conversation
With catch_errors_as_events=False, an exception raised by a guard or a callback of the internal events or eventless transitions that follow an external event left the events queued behind it in the queues, and on the async engine a coroutine awaiting one of them was never answered. Handle it like an exception raised by the external event: drop the queued events, internal and external, and reject their futures with the exception. Fixes #686 Signed-off-by: Fernando Macedo <fgmacedo@gmail.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #688 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 53 53
Lines 5816 5818 +2
Branches 926 926
=========================================
+ Hits 5816 5818 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Oct 13, 2026
Closed
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.



Why
On
mainafter #668, withcatch_errors_as_events=False(theStateMachinedefault), an exception escaping the internal events or eventless transitions that follow an external event leaves the events queued behind it in place. On the async engine, coroutines awaitingsend()of those events never return: 17 of the 43 new regression tests hit the 5 spytest-timeoutonmain. On the sync engine the queued events run later, as stale events, at the nextsend(). Fixes #686.What changes
send()future with that exception and drops every queued event (internal, external, delayed). This covers raising callbacks (before/on/after/enter/exit), guards and validators in the following macrostep, and a failed lazy initial activation.BaseEngine.clear()now clears the internal queue too, so internal events raised before a failure no longer run inside the next, unrelated event.StateChartwithcatch_errors_as_events=Trueis unchanged: errors becomeerror.execution, and queued callers get their results.docs/releases/3.2.2.md, macrostep section and upgrade bullet) anddocs/async.mdstate the contract and how it differs from v3.2.1, where the queued external events ran before the failing internal event.Evidence
v3.2.1 contract checked on a v3.2.1 worktree with a repro script (holder sends
go, two coroutines queuestep, the failure happens aftergo):New tests (
TestMacrostepErrorAnswersQueuedCallersintests/test_async_futures.py):Full suite, coverage, linters:
Three adversarial review rounds by fresh reviewers; round 1 found the sync guard path and leftover internal events, round 2 the docs scope, round 3 nothing material.
Not verified
CancelledErroris not anException) still strands queued callers, on v3.2.1 too.TransitionNotAllowedor a raising guard in an external event's own selection does not clear the queue (same as v3.2.1).handle_external_eventraising leaves that popped event's awaiting coroutine unanswered (pre-existing).tests/test_threading.py.