-
Notifications
You must be signed in to change notification settings - Fork 782
Description
Bug
In Rx 6.0.1, if you specify a short TimeSpan to Schedule, occasionally it will invoke your work item synchronously (i.e. it runs it before returning from Schedule, and does so on the caller's thread.) It's common to dispatch work via a scheduler to avoid stack overflows or deadlocks that can arise from synchronous execution of followup work, so this is unhelpful.
We only started seeing this in .NET 9.0. Having found the code, I don't see any reason why it wouldn't also occur in earlier versions, but perhaps there has been some change in either the Task or timer implementation in the CLR that makes it more likely.
There's also a problem with the tests that brought this to light: they were attempting to raise an assertion, but that assertion got lost, and the actual symptom was that the test timed out. This is because the tests used Assert inside the callback for the work item they scheduled, and they then did nothing to attempt to recover the outcome of that work and rethrow any exceptions back on the test thread. Consequently the assertion failure was essentially invisible to the test framework.