Skip to content

Add regression test for WaitAny join schedule-before-cancel ordering#7341

Merged
sfmskywalker merged 2 commits intobug/7335from
copilot/sub-pr-7340
Mar 2, 2026
Merged

Add regression test for WaitAny join schedule-before-cancel ordering#7341
sfmskywalker merged 2 commits intobug/7335from
copilot/sub-pr-7340

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

The WaitAny join in counter-based flowcharts had a latent ordering bug: canceling remaining inbound branches before scheduling the outbound activity meant CompleteIfNoPendingWorkAsync could fire while the outbound activity was not yet in the scheduler, causing the flowchart to complete prematurely without ever executing the downstream activity.

Changes

  • New regression test in FlowchartCounterBasedTestsWaitAnyJoin_SchedulesOutboundBeforeCancelingBlockedBranch

    • Forks into a fast WriteLine branch and a BlockingActivity (inner class that calls context.CreateBookmark(), simulating Delay/Timer suspension)
    • Both branches converge at FlowJoin(WaitAny)WriteLine("AfterJoin")
    • The LIFO stack scheduler guarantees the blocking branch runs and suspends before the fast branch, reproducing the exact live-bookmark scenario
  • Inner BlockingActivity — minimal sealed Activity subclass that suspends by creating a bookmark; no external dependency on Elsa.Workflows.Runtime required

Assertions

Assertion What it proves
"AfterJoin" in output Outbound path of the join actually executed
WorkflowStatus.Finished No premature completion while outbound was unscheduled
WorkflowState.Bookmarks empty Canceled branch's bookmark was cleared on cancellation

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…before-cancel regression test)

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Copilot AI changed the title [WIP] Update handling of inbound connection based on feedback Add regression test for WaitAny join schedule-before-cancel ordering Mar 2, 2026
@sfmskywalker sfmskywalker marked this pull request as ready for review March 2, 2026 18:52
@sfmskywalker sfmskywalker merged commit 34d6694 into bug/7335 Mar 2, 2026
3 checks passed
@sfmskywalker sfmskywalker deleted the copilot/sub-pr-7340 branch March 2, 2026 18:52
sfmskywalker added a commit that referenced this pull request Mar 2, 2026
…fore canceling remaining activities (#7340)

* Refactor inbound connection handling to schedule outbound activity before canceling remaining activities

* Add regression test for WaitAny join schedule-before-cancel ordering (#7341)

* Initial plan

* Add integration test for WaitAny join with blocking branch (schedule-before-cancel regression test)

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

Added a comprehensive regression test for the WaitAny join ordering bug (issue #7335) that was fixed in commit 82c69d0. The test creates a flowchart with one fast branch and one blocking branch (using a new BlockingActivity inner class) converging at a FlowJoin(WaitAny). The test validates that the outbound activity executes, the workflow completes properly, and bookmarks are cleared - ensuring the fix prevents premature workflow completion when the outbound activity wasn't yet scheduled.

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • Test-only change that adds a well-crafted regression test with clear documentation, appropriate assertions, and follows existing patterns in the test suite
  • No files require special attention

Important Files Changed

Filename Overview
test/integration/Elsa.Activities.IntegrationTests/Flow/FlowchartCounterBasedTests.cs Added well-documented regression test validating WaitAny join ordering fix with blocking branch scenario

Last reviewed commit: 5167c65

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.

2 participants