question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rx2: Multiple errors in zip'ed observables throw exception

See original GitHub issue

I execute multiple HTTP calls in parallel by zipping them up. Now 0…n of them can obviously fail. The thing is, when e.g. 2 calls fail at almost the exact time, error 1 is processed in doOnError and onErrorReturnItem but error 2 slips through and causes an exception. I think this happens if error 2 happens to come in while error 1 is still not processed entirely in those two onError operators.

It can be reproduced with the following simplified code:

buttonClick.flatMapSingle(action -> Single.zip(
                    Single.error(new Throwable("error 1")).delay(500, TimeUnit.MILLISECONDS),
                    Single.error(new Throwable("error 2")).delay(500, TimeUnit.MILLISECONDS),
                    (integer, integer2) -> true
            )
                    .doOnError(t -> Timber.d(t.getMessage()))
                    .onErrorReturnItem(true))
                    .subscribe();

So every once in a while this would throw:

D/Main: error 1
W/System.err: java.lang.Throwable: error 2

Shouldn’t the Single.zip stream only be allowed to emit one error?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
TillSimoncommented, Nov 22, 2016

It doesn’t seem to be happening with Observable.zip(), so I don’t know if that behavior makes sense…

0reactions
akarnokdcommented, Jan 19, 2017

I’m closing this issue due to inactivity. If you have further input on the issue, don’t hesitate to reopen this issue or post a new one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RxJava2: Multiple errors in zip'ed observables throw exception
Show activity on this post. I execute multiple HTTP calls in parallel by zipping them up. Now 0..n of them can obviously fail....
Read more >
RxJava and Error Handling - Baeldung
See how to deal with errors using RxJava. ... First, keep in mind that the Observable typically does not throw exceptions.
Read more >
RxRatpack (Ratpack API (2.0.0-rc-1))
Converts an Observable into a Promise , for all of the observable's items. This method can be used to simply adapt an observable...
Read more >
kotlinx-coroutines-rx2
Flow.asObservable, Observable, Converts the given flow to a cold Observable. ... Awaits for the value of the maybe and returns it or throws...
Read more >
Error Handling With Observable Sequences | RxJS
With the retry operator, we can try a certain operation a number of times before an error is thrown. This is useful when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found