Conversation
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.
Problem
ToObservableOptional(key, initialOptionalWhenMissing: true)decided whether to emit the synthetic initialNoneusing aseenValueflag written byDoon the source and read by an innerDeferon the merged second source. That read/write pair is not serialized with the source's notifications:Mergesubscribes to its inputs sequentially, but an already-subscribed asynchronous source can deliver a value while the second input is still being subscribed. TheDeferfactory could then observe a stalefalse, and the syntheticNonewould be delivered after a realSome, clobbering the current value with a spuriousNone.Fix
Initial-value selection is now serialized with source notifications rather than racing them. Values and the initialization marker are merged into a single notification stream, and the first-notification state is inspected and updated after
Mergehas already ordered them. The syntheticNoneis emitted only when it wins that serialized order, so it can only ever be the first notification; any laterNonecomes from a genuine source removal. State remains per-subscription, and error propagation, completion, and disposal stay owned by the Rx operators.Validation
Focused concurrency tests for this behavior were added and passed during prior validation of this change (
ToObservableOptionalFixture.InitialValue.cs). No unrelated fixes are included in this PR.Docs
Updated the cache operator reference for
ToObservableOptionaland the Rx guidance on distinguishing subscription order from notification order, using this operator as the worked example.Fixes #1178