Skip to content

Fix the mail wake coordinator test's dropped cancellation event - #10344

Merged
glen-84 merged 1 commit into
mainfrom
gai/mail-wake-cancel-callback-race
Sep 3, 2026
Merged

glen-84 merged 1 commit into
mainfrom
gai/mail-wake-cancel-callback-race

Conversation

@glen-84

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

Copy link
Copy Markdown
Member

Summary

  • MailWakeDaemonCoordinatorTests.RunningLeader_Should_ReleaseLeadership_And_CancelSiblings_When_AccessDeniedReleaseIsBusy intermittently failed in CI (for example run 33753963774, net11.0 with --coverage) with Expected "hung-actor-cancelled" before "release-attempted". Events: [release-attempted, release-attempted].
  • The DeniedThenHangingDispatcher fake recorded that event from a CancellationToken.Register callback held by await using, then awaited an infinite Task.Delay on the same token. Callbacks run in LIFO order, so Task.Delay's later registration fired first, the method unwound, and disposing the registration unregistered the fake's callback before it had run.
  • The callback now also completes a TaskCompletionSource, and the fake awaits it before returning, so the registration is disposed only after the event is recorded. MailWakeDaemonCoordinator is unchanged; it already awaits CancelAsync before releasing the lease.

Test plan

  • Built Nitro.CommandLine.Tests for net11.0 with CI_BUILD=true and ran the single test 40 times with --coverage under 24 busy-loop processes: 40 passes. The same setup reproduced the failure without the change.
  • Ran the full Nitro.CommandLine.Tests suite on net11.0: 3599 passed, 0 failed.

Copilot AI lite review requested due to automatic review settings September 3, 2026 13:03

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.

🟢 Approval recommended

The change is a targeted, test-only synchronization fix that deterministically preserves the intended event recording behavior and aligns with the PR’s documented failure mode.

Pull request overview

This PR stabilizes an intermittently failing Nitro.CommandLine.Tests test by ensuring a cancellation callback event is reliably recorded before the callback registration is disposed, preventing flaky event-order assertions in CI runs.

Changes:

  • Update DeniedThenHangingDispatcher to coordinate cancellation callback execution via a TaskCompletionSource.
  • Ensure the fake dispatcher does not return until its CancellationToken.Register callback has run and recorded the expected event.
File summaries
File Description
src/Nitro/CommandLine/test/CommandLine.Tests/Services/Notify/MailWakeDaemonCoordinatorTests.cs Makes the dispatcher fake wait for its cancellation callback to run before disposing the registration, removing a source of flaky event ordering.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

✅ Nitro CLI E2E snapshots: no flow recordings changed vs main.

@glen-84
glen-84 merged commit 78c6cca into main Sep 3, 2026
152 checks passed
@glen-84
glen-84 deleted the gai/mail-wake-cancel-callback-race branch September 3, 2026 13:17
This was referenced Oct 25, 2026
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