Repository navigation
fix: stop notification delivery after subscription disposal - #252
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #252 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1013 1014 +1
Lines 27204 27251 +47
Branches 3278 3291 +13
=========================================
+ Hits 27204 27251 +47 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- Clear observer and action targets atomically when disposing Signal<T> subscriptions so in-flight terminal snapshots cannot deliver OnError or OnCompleted or rethrow for disposed action subscribers - Wrap Witness.Subscribe callback subscriptions in a disposable unary witness slot that suppresses post-disposal and duplicate terminal notifications while keeping internal coordinator callback subscriptions on EmptyWitness<T> - Stop SerializedWitness delivery immediately when ReplaySignal, BehaviorSignal, or StateSignal subscriptions dispose during an active broadcast, and ensure single-winner detachment in BehaviorWitnessHandler<T> - Share DetachableObserver<TOwner, T> across DelayableNotificationSignal, ProjectedReadOnlyState, SliceWindow, and AsyncSignal so reentrant sibling disposal halts delivery immediately - Add regression and direct observer-handle tests covering Signal.Create sibling teardown and mid-broadcast subscription disposal
glennawatson
force-pushed
the
fix/disposed-subscription-delivery
branch
from
November 21, 2026 06:25
66fbca9 to
ee5452f
Compare
|
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.



Summary
Stops notification delivery as soon as a subscription handle is disposed, including when one subscriber synchronously disposes a sibling subscription during an active broadcast.
Signal<T>subscriptions now clear their observer and action targets on disposal so captured terminal snapshots neither deliverOnErrororOnCompletednor rethrow for disposed action subscribers.Witness.Subscribecallback overloads now guard callbacks with a disposable witness so disposed or terminated subscriptions ignore later notifications from anyIObservable<T>, while internal coordinators keep lightweightEmptyWitness<T>subscriptions under their own state guards.ReplaySignal<T>,BehaviorSignal<T>, andStateSignal<T>now callSerializedWitness<T>.Stop()on subscription disposal (with single-winner detachment inBehaviorWitnessHandler<T>) so serialized delivery halts immediately during an active broadcast.DelayableNotificationSignal<T>,ProjectedReadOnlyState<TSource, TResult>,SliceWindow<T>, andAsyncSignal<T>now detach downstream observers on disposal before an in-flight fan-out reaches them.Why
When an observable built with
Signal.Createfaults or completes throughSubscribeSafe, the outer sink tears down its subscription resource synchronously before forwarding the terminal signal. Any sibling subscriptions disposed by that cleanup could still receiveOnErrororOnCompletedfrom the upstream subject's captured observer array after their ownDisposehad already run.Closes #251
Breaking changes
None
How this was verified
Added unit tests covering
Signal.Createsibling teardown on error and completion, mid-broadcast sibling disposal across synchronous signals and windows, post-disposal suppression inWitness.Subscribe, and directIObserver<T>handle disposal paths, and ran the reproduction program from #251.Notes for the reviewer
Start with
Signal<T>.SignalSubscriptionandWitness.SubscribeCallbacks, which address the two mechanisms behind #251 directly. TheDetachableObserver<TOwner, T>andSerializedWitness<T>.Stop()updates apply the same guarantee across the remaining synchronous fan-out types.Checklist