3.x: Fix delay-cancellation race producing random subsequent emissions#7855
Merged
akarnokd merged 1 commit intoReactiveX:3.xfrom May 19, 2025
Merged
3.x: Fix delay-cancellation race producing random subsequent emissions#7855akarnokd merged 1 commit intoReactiveX:3.xfrom
akarnokd merged 1 commit intoReactiveX:3.xfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 3.x #7855 +/- ##
============================================
- Coverage 99.62% 99.62% -0.01%
Complexity 6801 6801
============================================
Files 752 752
Lines 47707 47715 +8
Branches 6401 6404 +3
============================================
+ Hits 47527 47534 +7
+ Misses 84 80 -4
- Partials 96 101 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a sequence using
delayis cancelled asynchronously, there is a race between cancelling each individualFutureinside the executor and them running, causing skips in theonNextemissions.For example, let's say there are 3 futures waiting to be executed. The Future-1 triggers the cancellation asynchronously and emits
1. This asynchronous routine will start cancelling Future-2 and Future-3 one by one. Concurrently, the executor will look at Future-2, see it cancelled and moves onto Future-3, which is still executable as the asynchronous routine hasn't gotten to cancel Future-3. Now Future-3 runs and emits3. This will appear to produce a sequence of[1, 3]where2is missing.The fix is to hard-check for a disposed worker and prevent the
onNextemissions in the operator.Resolves #7851