It seems that using this extension within streams that leverage
combine
or
flatMapLatest
, or any operators that cause downstream cancellations where
ObservableSource.asFlow()
is used in the downstream may run into race conditions where the Coroutine might get cancelled concurrently while the Rx
Observable
is still emitting, causing a
JobCancellationException
or a
ChildCancelledException
.
Marcelo Hernandez
10/12/2020, 9:04 PM
I wish I had a solid and consistent repro, but unfortunately that is currently not the case. 😞
w
wbertan
10/13/2020, 8:08 AM
I got what I think similar case with Rx 😞
In my case I did
dispose
which then something finished and throw exception and I got
io.reactivex.exceptions.UndeliverableException
(The code contains a proper error handler - where usually was the reason for this error)
So I found this issue in GitHub: https://github.com/ReactiveX/RxJava/issues/4991 with this comment:
This is by design, your Callable crashes and the downstream has disposed so the operator routes the error to the global error handler as it can’t know if the exception is relevant or not. Don’t crash into RxJava and consider using create() with emitter.tryOnError() instead.
wbertan
10/13/2020, 8:11 AM
The problem in my case the “Callable crash” was in Retrofit as the exception is:
Copy code
Caused by retrofit2.adapter.rxjava2.HttpException
HTTP 404 Client Error
So not sure if in my case I would be able to handle better as the comment suggests with
create()
and `emitter.tryOnError()`…
Anyway, it was the first time we notice this kind of Exception like this, and it was in our Alpha build (internal), so we will keep an eye and if becomes more often we will act on it.