Skip to content

Fix failing 'Should run pre-middlewares for sync workflows' unit test - #1455

Merged
danielgerlag merged 3 commits into
masterfrom
fix/sync-premiddleware-test
Oct 25, 2026
Merged

danielgerlag merged 3 commits into
masterfrom
fix/sync-premiddleware-test

Conversation

@danielgerlag

Copy link
Copy Markdown
Owner

Root cause

The test only checks that pre-middleware runs, but the workflow under test could never finish: the faked IExecutionResultProcessor never ended the execution pointer, so SyncWorkflowRunner kept looping until the 1 ms timeout cancelled the token. The cancelled token then surfaced as a TaskCanceledException from PersistWorkflow (SyncWorkflowRunner.cs:97), failing the test. Pre-middleware itself was running fine; this is a test setup issue, not a runner bug.

Fix (test only)

  • Make the fake result processor end the pointer (Active = false, EndTime set) so the one-step workflow actually completes.
  • Use a 30 s timeout as a safety net instead of 1 ms.
  • Also assert the workflow reaches Complete.

Testing

  • WorkflowCore.UnitTests: 62/62 on net6.0, net8.0 and net10.0, 5 runs in a row each (test now ~0.3 s).
  • WorkflowCore.IntegrationTests: 45/45 on net6.0, net8.0 and net10.0.

@danielgerlag
danielgerlag requested a review from glucaci as a code owner October 22, 2026 14:21
Events that run through EventConsumer with no matching subscription were
marked processed. When a later WaitFor then unprocessed and requeued the
set, a later EventTime sibling could be dequeued while earlier siblings
were still marked processed, so SeedSubscription skipped its ordering
guard (EventOrderScenario: Expected Value2=2, found 5).

- Leave unsubscribed events unprocessed (greylist to avoid poller spin)
- Unprocess the full sibling set before requeueing any of them
- Walk siblings by EventTime when enforcing order
RetrySagaWithUserTaskScenario polls open user actions on a live
WorkflowInstance while the host mutates ExecutionPointers, which can
throw "Collection was modified" from Dictionary.Values enumeration.
Retry the snapshot a few times instead of failing the caller.
@danielgerlag
danielgerlag merged commit 3e4c5f0 into master Oct 25, 2026
10 of 11 checks passed
@danielgerlag
danielgerlag deleted the fix/sync-premiddleware-test branch October 25, 2026 17:36
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.

1 participant