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.

rxAwait calls the uncaught exception handler

See original GitHub issue

Why does the following code calls the uncaught exception handler?

As there is an onError supplied I expect it to be called instead.

import io.reactivex.Observable
import io.reactivex.Single
import kotlinx.coroutines.experimental.rx2.await
import kotlinx.coroutines.experimental.rx2.rxSingle
import java.io.IOException
import java.util.concurrent.TimeUnit

fun main(args: Array<String>) {
  Observable
    .interval(1, TimeUnit.MILLISECONDS)
    .switchMapSingle {
      rxSingle {
        timeBomb().await()
      }
    }
    .subscribe({}, {})

  Thread.sleep(1000)
}

private fun timeBomb() = Single.timer(1, TimeUnit.MILLISECONDS)
  .doOnSuccess { throw IOException("") }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:21 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
qwwdfsadcommented, Oct 29, 2019

@fabioCollini yes, I’ve made the fix for 1.3.3. The current solution is to report undeliverable exceptions to RxJavaPlugins, so @jcornaz example without coroutines and original one work similarly.

0reactions
fabioCollinicommented, Oct 16, 2019

Hey everyone, any updates about this issue? We had the same problem described in this issue, we have fixed it using the RxCoroutineExceptionHandler in all the rxSingle/rxCompletable invocation.

Is this the best way to solve it? Should RxCoroutineExceptionHandler be included in the library as default exception handler for all the methods that transforms a suspending method into an rx object?

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Why is UncaughtExceptionHandler not called by ...
Because the exception does not go uncaught. The Thread that your ThreadFactory produces is not given your Runnable or Callable directly.
Read more >
Thread.UncaughtExceptionHandler (Java Platform SE 7 )
Interface for handlers invoked when a Thread abruptly terminates due to an uncaught exception. When a thread is about to terminate due to...
Read more >
Rx to Coroutines Concepts, Part 2.1: Exceptions
This means that any uncaught exception in any child coroutine terminates the whole coroutineScope. So say that you try and handle these ...
Read more >
Coroutine exceptions handling | Kotlin
This section covers exception handling and cancellation on exceptions. We already know that a cancelled coroutine throws ...
Read more >
Exceptions in coroutines. Cancellation and Exceptions in…
Handling exceptions properly has a huge impact on how users perceive your ... Uncaught exceptions will always be thrown regardless of the kind...
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