Skip to content

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

Merged
sfmskywalker merged 2 commits intorelease/3.6.0from
bug/7335
Mar 2, 2026
Merged

Refactor inbound connection handling to schedule outbound activity before canceling remaining activities#7340
sfmskywalker merged 2 commits intorelease/3.6.0from
bug/7335

Conversation

@sfmskywalker
Copy link
Member

No description provided.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 2, 2026

Greptile Summary

This PR refactors the FlowJoinMode.WaitAny handling in the flowchart counter-based logic to schedule the outbound activity before canceling remaining inbound activities.

  • Changed the order of operations in MaybeScheduleWaitAnyActivityAsync method (lines 316-321)
  • Now schedules the outbound activity first, then cancels remaining inbound activities
  • Updated inline comments to reflect the new execution order
  • This defensive refactoring ensures the continuation is queued in the scheduler before any cleanup or side effects from cancellation occur

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a small, well-contained refactoring that reorders two async operations. Scheduling the outbound activity before canceling inbound activities is a defensive improvement that prevents potential race conditions. The logic is straightforward, comments were updated appropriately, and the return value handling is correct.
  • No files require special attention

Important Files Changed

Filename Overview
src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.Counters.cs Reordered operations in WaitAny join handling to schedule outbound activity before canceling remaining inbound activities, improving execution safety

Last reviewed commit: 82c69d0

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors counter-based flowchart inbound connection handling for FlowJoinMode.WaitAny to ensure the outbound activity is scheduled before canceling remaining inbound/ancestor activities, preventing premature completion paths during cancellation.

Changes:

  • Reorders WaitAny handling to schedule the outbound activity first, then cancel remaining inbound activities.
  • Captures the schedule result in a local variable and returns it after cancellations complete.

Copy link
Contributor

Copilot AI commented Mar 2, 2026

@sfmskywalker I've opened a new pull request, #7341, to work on those changes. Once the pull request is ready, I'll request review from you.

…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>
@sfmskywalker sfmskywalker merged commit d4b69be into release/3.6.0 Mar 2, 2026
2 of 3 checks passed
@sfmskywalker sfmskywalker deleted the bug/7335 branch March 2, 2026 18:53
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.

"Lost an owner context" error while trying to complete a Join activity using WaitAny, on a workflow using a before/after/always commit strategy.

3 participants