Skip to content

[Fusion] Fix flaky NATS broker dispose test race - #10046

Merged
glen-84 merged 2 commits into
mainfrom
gai/nats-broker-dispose-test-race
Jul 3, 2026
Merged

glen-84 merged 2 commits into
mainfrom
gai/nats-broker-dispose-test-race

Conversation

@glen-84

@glen-84 glen-84 commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

  • DisposeAsync_Should_DisposeBrokerConnection_When_BrokerIsDisposed started a fire-and-forget MoveNextAsync() and then disposed the subscription enumerator while it was still pending. Disposing an IAsyncEnumerator mid-MoveNextAsync is illegal, so the compiler-generated async iterator threw NotSupportedException ("Specified method is not supported.") under CI threadpool contention.
  • The test now awaits the in-flight subscription before the enumerator is disposed, and asserts that disposing the broker cancels its active subscription. The iterator is never disposed while a MoveNextAsync is running, and block 1 gains a real assertion (it previously had none).
  • Test-only change; no product code is affected.

Test plan

  • Reproduced the exact exception deterministically with a standalone async-iterator repro (unawaited MoveNextAsync + DisposeAsync).
  • Ran the fixed test 30x under multicore CPU stress — all green.

Copilot AI review requested due to automatic review settings July 3, 2026 15:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a race in the Fusion NATS subscription dispose test by ensuring an in-flight MoveNextAsync() is awaited (and observed) before the async enumerator is disposed, preventing illegal mid-MoveNextAsync disposal behavior.

Changes:

  • Capture the in-flight MoveNextAsync() task instead of fire-and-forget.
  • Dispose the broker and assert that the active subscription is canceled, avoiding disposing an async iterator while it is running.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@glen-84
glen-84 merged commit 20a1c0b into main Jul 3, 2026
146 checks passed
@glen-84
glen-84 deleted the gai/nats-broker-dispose-test-race branch July 3, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants