I'm trying to debug an exception that gets thrown ...
# coroutines
j
I'm trying to debug an exception that gets thrown deep inside some coroutine calls. I'm using Spring and I'd like
kotlinx.coroutines.debug
to be enabled both in production and in tests, so I've added a
@Configuration
and I've confirmed that this runs:
Copy code
DebugProbes.sanitizeStackTraces = false
DebugProbes.enableCreationStackTraces = enableCreationStackTraces // disabled for prod, enabled for tests

System.setProperty(
  kotlinx.coroutines.DEBUG_PROPERTY_NAME,
  kotlinx.coroutines.DEBUG_PROPERTY_VALUE_ON
)

DebugProbes.install()
But I still get a super limited stack trace when I run my test. Is this the right way to set it up? I've also added a
@CoroutinesTimeout
to my test class but that didn't help either. What am I missing?
r
j
Thanks 🙂 ended up using this and it works - although it's a bit worrying that this functionality requires a third party library. Would have thought I could get it working with the official Kotlin one
r
The official Kotlin solution for stack trace recovery works only when the exception submitted to the coroutine explicitly (through method “resumeWith”). Decoroutinator works in any case. If you’d like to support Decoroutinator officially please vote for https://youtrack.jetbrains.com/issue/KT-50720/Kotlinx.coroutines-debugging-Support-Stacktrace-decoroutinator-like-solution.
j
Thanks, voted! Didn't realise you were the author at first. Congrats for the cool library, appreciate your effort 🙏
🎉 1