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
I found a use case where the unsafeSubscribe combined with Scheduler since 0.17.5 can cause a hang in certain cases because a terminal event (onError in this case) never gets emitted.
In this case, if the Observable being subscribed to throws an exception (breaks the contract) instead of using onError the Exception is completely swallowed because it's inside a Scheduler on another thread.
Because it's inside a Scheduler the catch-all inside lift does not help this case.
There are two options as I see it:
Make every use of unsafeSubscribe inside a Scheduler try/catch/onError
Make unsafeSubscribe just a tad safer for the broken contract case
Option 1 is not great as all it takes is one mistaken place and we end up with code that hangs without any clue as to why.
Option 2 is simple, no cost and solves it everywhere. It does not defeat the reason for unsafeSubscribe as this will not involve SafeSubscriber, plugin invocation or anything else that should only happen with subscribe.
I found a use case where the
unsafeSubscribe
combined withScheduler
since 0.17.5 can cause a hang in certain cases because a terminal event (onError
in this case) never gets emitted.Here is an example:
In this case, if the
Observable
being subscribed to throws an exception (breaks the contract) instead of usingonError
the Exception is completely swallowed because it's inside aScheduler
on another thread.Here's a unit test demonstrating it:
Because it's inside a
Scheduler
the catch-all insidelift
does not help this case.There are two options as I see it:
unsafeSubscribe
inside aScheduler
try/catch/onErrorunsafeSubscribe
just a tad safer for the broken contract caseOption 1 is not great as all it takes is one mistaken place and we end up with code that hangs without any clue as to why.
Option 2 is simple, no cost and solves it everywhere. It does not defeat the reason for
unsafeSubscribe
as this will not involveSafeSubscriber
, plugin invocation or anything else that should only happen withsubscribe
.The code will change from:
to
The text was updated successfully, but these errors were encountered: