I have a custom scope built like this ``` ...
# coroutines
r
I have a custom scope built like this
Copy code
CoroutineScope(Dispatchers.Default + CoroutineExceptionHandler { _, e ->
                    log.error("Uncaught error in scope", e)
                })
But it looks like when an error occurs, or rather after a few errors, coroutines basically stop like if the scope was dead or something. Eveyrthing seems stuck. Does calling the CoroutineExceptionHandler cancel the scope’s job or something? Do I need to specify a
+ SupervisorJob()
when building the scope? I don’t really understand what’s happening
k
What you describe is standard
Job()
behavior - when error occurs, parent cancel child jobs and propagates error up (until scope reached). When that happens (and scope is cancelled) you no longer can use it. And yes, using SupervisorJob replaces that behavior - it’ll not cancel other children and stop error propagation
☝️ 1
r
Thanks! I guess I just didn’t expect a CoroutineScope to have a
Job
and not a
SupervisorJob
by default
l
@ribesg
MainScope()
will use a
SupervisorJob
though.
👍 1