Skip to content

[Internal] Tests: Fixes AppCancellationDuringHedging with deterministic synchronization#5712

Merged
kirankumarkolli merged 1 commit into
masterfrom
users/nalutripician/test-fix-hedging-cancellation
Mar 19, 2026
Merged

[Internal] Tests: Fixes AppCancellationDuringHedging with deterministic synchronization#5712
kirankumarkolli merged 1 commit into
masterfrom
users/nalutripician/test-fix-hedging-cancellation

Conversation

@NaluTripician
Copy link
Copy Markdown
Contributor

Summary

Replaces timing-dependent cancellation pattern with deterministic TaskCompletionSource + ct.Register() approach in the AppCancellationDuringHedging_DoesNotSpawnNewHedgeRequests test.

Root Cause

The test used a 10ms threshold with a 15ms cancellation delay, giving only 5ms margin. Task.Delay precision at these scales is unreliable on loaded CI agents, causing the test to fail ~4% of the time.

Fix

  • Cancel the app token immediately on the first request (deterministic)
  • All requests block via TaskCompletionSource until cancelled via the cancellation token
  • No more timing dependencies — the test is now fully deterministic

Test Fixed (95.89% pass rate — 29 failures in 30 days)

  • AppCancellationDuringHedging_DoesNotSpawnNewHedgeRequests

Impact

…ic synchronization

Replaces timing-dependent Task.Delay cancellation pattern with
deterministic TaskCompletionSource + ct.Register() approach.
Previously used 10ms threshold + 15ms cancel delay (5ms margin),
which was unreliable on loaded CI agents.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kirankumarkolli kirankumarkolli merged commit f406a68 into master Mar 19, 2026
33 checks passed
@kirankumarkolli kirankumarkolli deleted the users/nalutripician/test-fix-hedging-cancellation branch March 19, 2026 23:31
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