Heads up for anyone in/around Leuven (Belgium) in ...
# coroutines
t
Heads up for anyone in/around Leuven (Belgium) in September. @amanda.hinchman-dominguez (kotlinx.coroutines-adjacent, speaking at KTConf) is running a pre-conference workshop the day before: Kotlin Coroutines Forensics Masterclass. Full day, hands-on, digging into leak detection, Perfetto profiling, structured concurrency patterns, ... basically the stuff that usually only bites you in production. She's already going to be in town for KTConf, so it's a good opportunity to get a full day with her rather than just a regular talk. Also: has anyone here hit a nasty coroutine race condition or leak in prod? I'm collecting real stories for the workshop marketing, happy to credit/anonymize as preferred. Btw I'm also posting this in #android and #server, couldn't really find a good channel to actually post this, because it's sort of an advertisement and a call for help at the same time. Struggling a lot with the balance between "this is probably useful info for kotlinlang members to know" and basically spamming people in here... If you've got better ideas how to deal with that, feel free to hit me up as well 😮‍💨
c
A leak in prod: I had some code like
Copy code
class Foo(
    parent: CoroutineContext,
) {
    private val scope = CoroutineScope(parent + SupervisorJob(parent.job))

    // …

    suspend fun results(): FooResults {
                scope.coroutineContext.job.children.toList().joinAll()
        return results
    }
}
We did not notice, but nothing anywhere completes the job, so this does return results, and then the scope continues to exists forever so the parent coroutine cannot ever finish. We therefore had endpoints that would correctly respond, and then would hang forever, never freeing their resources
😮 2
🙏 2
a
@CLOVIS ah yea, that's a classic silent hang! Where it gets tricky is that nested
SupervisorJob(parent.job)
inside a custom scope, and that's because a cancellation signal can be sent downstream, but completion cannot be signaled upstream due to the boundaries a scope draws around a job. This pattern is actually one of the scenarios we're breaking down in the workshop. Mind if we share this example as well? Thanks for sharing this one. If your team has interest in learning more about the workshop, hit me or @Tim Schraepen up for additional details.
c
You can use the example if you want. I know about the workshop, I was at KTConf last year… I'm not able to attend this year though 😕
kodee sad 1