Skip to content

UndeliverableException #6249

Closed
Closed
@juliocbcotta

Description

@juliocbcotta

I am faciing an UndeliverableException case when using a Single.zip and multiple sources from retrofit fail to load the data from the network. I expected that when the first error happens the other streams would be disposed, but it seems it is not the case as the

  • version 2.2.2

  • stacktrace

io.reactivex.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.net.UnknownHostException: Unable to resolve host "my.domain.com": No address associated with hostname
at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)  
at io.reactivex.internal.operators.single.SingleZipArray$ZipCoordinator.innerError(SingleZipArray.java:139)    
at io.reactivex.internal.operators.single.SingleZipArray$ZipSingleObserver.onError(SingleZipArray.java:175)
at io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onError(SingleMap.java:69)
at io.reactivex.internal.observers.ResumeSingleObserver.onError(ResumeSingleObserver.java:51)
at io.reactivex.internal.disposables.EmptyDisposable.error(EmptyDisposable.java:78)
at io.reactivex.internal.operators.single.SingleError.subscribeActual(SingleError.java:42)
at io.reactivex.Single.subscribe(Single.java:3438)
at io.reactivex.internal.operators.single.SingleResumeNext$ResumeMainSingleObserver.onError(SingleResumeNext.java:80)
at io.reactivex.internal.operators.observable.ObservableSingleSingle$SingleElementObserver.onError(ObservableSingleSingle.java:93)
at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeOnObserver.onError(ObservableSubscribeOn.java:63)
override fun getFieldsDetails(): Single<List<FieldDetail>> {
        return service.getFields()
                .flatMap { fields ->
                    if (fields.isEmpty()) {
                        Single.just(emptyList())
                    } else {
                        Single.zip(fields.map { field ->
                            service.getFieldDetail(field)
                        }) { it ->
                            it.filterIsInstance<FieldDetail>()
                        }
                    }
                }
    }

It looks like this issue from retrofit repo square/retrofit#2487 . If that is not a retrofit problem, what can be done to avoid this crash?

Activity

akarnokd

akarnokd commented on Oct 16, 2018

@akarnokd
Member

Please read the exception message and the linked wiki section:

io.reactivex.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.net.UnknownHostException: Unable to resolve host "my.domain.com": No address associated with hostname

juliocbcotta

juliocbcotta commented on Oct 16, 2018

@juliocbcotta
Author

@akarnokd I have read the docs, but that does not seems to anwser my question.
Is this the expected behavior? If so, what can I do as developer to handle this from my side as from
setting an RxJavaPlugins.setErrorHandler seems to be an exagerad option.
If this is my ONLY option, how to keep the original error handling for other cases and still avoid the app to crash in this case?

akarnokd

akarnokd commented on Oct 16, 2018

@akarnokd
Member

The detailed error message and the wiki link has the implication that such cases are expected and you can't do much about them: either you set the global error handler or you don't crash into RxJava.

In your specific case, zip can only deal with one of its sources failing. If multiple sources fail, RxJava can't tell if those other exceptions are significant for you and it can call onError again either. Thus it goes to the last resort handler as described in the wiki.

ldlywt

ldlywt commented on Jun 2, 2020

@ldlywt

private fun setRxJavaErrorHandler() { RxJavaPlugins.setErrorHandler(Throwable::printStackTrace) }

atif-afridi

atif-afridi commented on Dec 26, 2021

@atif-afridi

Hi ,
i taught to ask here rather starting new thread , i am facing the same error and i am not clear the reason for it.
PS : the code is open source and is already working in a sample project but not in my project , every dependency is added with all imports but still.

io.reactivex.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.lang.NoSuchMethodError: No direct method <init>(Lkotlin/coroutines/CoroutineContext;Z)V in class Lkotlinx/coroutines/AbstractCoroutine; or its super classes (declaration of

Thanks

akarnokd

akarnokd commented on Dec 26, 2021

@akarnokd
Member

@atif-afridi

java.lang.NoSuchMethodError: No direct method (Lkotlin/coroutines/CoroutineContext;Z)V in class Lkotlinx/coroutines/AbstractCoroutine; or its super classes (declaration of

Looks like your project is not properly setup or uses multiple modules with wrong dependency distribution. Also found this.

atif-afridi

atif-afridi commented on Dec 27, 2021

@atif-afridi

@akarnokd

Thanks for the quick response.
sure i will check if something is missing.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @juliocbcotta@akarnokd@atif-afridi@ldlywt

        Issue actions

          UndeliverableException · Issue #6249 · ReactiveX/RxJava