I am wondering how I should launch my couroutines in this scenario:
fun main () {
// setup with suspending calls
one().await()
two().await()
three().await()
// sequencial code here
}
I can’t run the suspending block in “runBlocking” as it’s not available in JS. It works fine if I mark main itself as suspend but then I get this exception once my call hierachy get’s to deep:
Exception in completion handler ResumeAwaitOnCompl…d by RangeError: Maximum call stack size exceeded"
The official solution is to either use suspend main or to run root coroutine via GlobalScope.launch and then live entirely in suspend world. There is also this issue. I do not recommend to use this approach for simply going into suspend world, but it could solve similar problems.