You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, we believe we have identified a race condition in the Throttle operator:
Which library version?
Reproduced in 4.1.0 and 5.0.0
What are the platform(s), environment(s) and related component version(s)?
Reproduced with
Windows 10 20H2
.NET 5.0 (with system.reactive 5.0.0)
.NET Framework 4.8 (with system.reactive 4.1.0)
What is the use case or problem?
If a second event arrives at the Throttle(TimeSpan dueTime) operator at almost exactly the same time as a cached event is due to be propagated, then neither will be emitted. I have reproduced this with Throttle(TimeSpan.Zero) but believe that it could happen with any timespan if a second or subsequent event arrives at an inopportune time.
If two items arrive at OnNext in quick succession:
OnNext(1):
hasValue = true, value = 1, id = 100 (let's say)
schedules Propagate(1)
OnNext(2):
hasValue = true, value = 2, id = 101
schedules Propagate(2)
Propagate(1):
hasValue is true but id doesn't match so doesn't forward value
clears hasValue
Propagate(2):
id matches but hasValue is false, so doesn't forward value
What is the expected outcome?
An event is emitted if no further events are received within the Throttle dueTime.
What is the actual outcome?
No event is emitted
What is the stacktrace of the exception(s) if any?
N/A
Do you have a code snippet or project that reproduces the problem?
Example .NET 5 console app referencing System.Reactive 5.0.0
usingSystem;usingSystem.Reactive.Disposables;usingSystem.Reactive.Linq;while(true){varsource=Observable.Create<int>(o =>{o.OnNext(1);o.OnNext(2);returnDisposable.Empty;});vari=0;try{while(true){i++;awaitsource.Throttle(TimeSpan.Zero).Timeout(TimeSpan.FromMilliseconds(100)).Take(1);}}catch(TimeoutException){Console.WriteLine($"Failed after {i} iterations");}}
The text was updated successfully, but these errors were encountered:
Hello, we believe we have identified a race condition in the
Throttle
operator:Reproduced in 4.1.0 and 5.0.0
Reproduced with
Windows 10 20H2
.NET 5.0 (with system.reactive 5.0.0)
.NET Framework 4.8 (with system.reactive 4.1.0)
If a second event arrives at the
Throttle(TimeSpan dueTime)
operator at almost exactly the same time as a cached event is due to be propagated, then neither will be emitted. I have reproduced this withThrottle(TimeSpan.Zero)
but believe that it could happen with any timespan if a second or subsequent event arrives at an inopportune time.A review of the code suggests the following interaction can occur between Throttle._.OnNext and Throttle._.Propagate
If two items arrive at
OnNext
in quick succession:OnNext(1):
OnNext(2):
Propagate(1):
Propagate(2):
An event is emitted if no further events are received within the Throttle dueTime.
No event is emitted
N/A
Example .NET 5 console app referencing System.Reactive 5.0.0
The text was updated successfully, but these errors were encountered: