-
-
Couldn't load subscription status.
- Fork 1.1k
Fix race condition in ReactiveCommand cancellation test #4196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
…ecutingFalseOnlyAfterCancellationCompleteAsync Added Task.Yield() after IsExecuting subscription to ensure the subscription is fully established before executing the command. This prevents a race condition where the first IsExecuting=true emission could be missed if the subscription wasn't fully set up yet. Co-authored-by: glennawatson <5834289+glennawatson@users.noreply.github.com>
Fixed the test failure and completed all prerequisites:
The intermittent test failure was caused by a race condition where the Test results:
Fixed in commit 53985ff Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot remember the prereq, install .net 8/9/10, unshallow, workflow restore still getting issues in the build |
Replaced Task.Yield() with a more robust approach that waits for the IsExecuting observable to emit its first value before calling Execute(). This ensures the subscription is fully established and has received the initial state before execution begins, eliminating the race condition more reliably. Co-authored-by: glennawatson <5834289+glennawatson@users.noreply.github.com>
Improved the fix with a more robust approach. The issue was that Updated fix: Now using Test results after completing prerequisites (install .NET 10, unshallow, workload restore):
Fixed in commit 0a2e256 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4196 +/- ##
=======================================
Coverage 34.24% 34.24%
=======================================
Files 144 144
Lines 6240 6240
Branches 926 926
=======================================
Hits 2137 2137
Misses 3936 3936
Partials 167 167 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fixes an intermittent test failure in
ReactiveCommandCreateFromTaskThenCancelSetsIsExecutingFalseOnlyAfterCancellationCompleteAsynccaused by a race condition.Root Cause
The test was experiencing intermittent failures where
IsExecutingwould beFalsewhen expected to beTrue. This occurred due to a race condition where the subscription to theIsExecutingobservable might not receive the initial value before the command starts executing, causing the firstIsExecuting = truenotification to be missed.Changes Made
Added synchronization using
TaskCompletionSourceto wait for theIsExecutingobservable to emit its first value before callingExecute(). This ensures the subscription is fully established and has received the initial state before execution begins, eliminating the race condition reliably.The fix waits for the first emission from
IsExecuting(which should befalseinitially) before starting command execution, guaranteeing that subsequent emissions (including thetruevalue when execution starts) will be captured by the subscription.Testing
The fix is minimal and surgical, affecting only the test timing to ensure reliable execution without changing any production code or test assertions.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.