Is there a way to stop Kotlin from ruining stack t...
# coroutines
s
Is there a way to stop Kotlin from ruining stack traces when suspending?
🚧 1
🧌 1
v
s
I don't really understand that, I'm not sure that's gonna solve my issue.
Consider this code:
Copy code
import kotlinx.coroutines.experimental.delay
import kotlinx.coroutines.experimental.runBlocking

suspend fun subfunction() {
    println("One")
    delay(10)
    println("Two")
}

suspend fun someMethodTree() {
    subfunction()
}

suspend fun whatever() {
    someMethodTree()
}

fun main(args: Array<String>) {
    runBlocking {
        whatever()
    }
}
The stack trace at the "One" println would contain the methods leading up to it (whatever and someMethodTree), whereas at "Two", after the suspend on delay(), it would instead show the caller as "doResume", with the rest of the stack entries missing (instead it's all event loop internals and such)
v
yes, that’s exactly what this issue is about. In 1.3 debugger will be able to recover stacktrace using new metadata
đź‘Ť 3
s
Ah, even in stack traces printed at runtime?
v
No, we can’t change the runtime. Though maybe there will be a way to print a stacktrace using debug metadata
s
Any idea how something like Python or JavaScript handles the same thing? It "just kinda works" there.
v
By having its own runtime. Kotlin works on top of JVM, we cannot modify JVM to tell it “here is the stacktrace we want to recover”