Hong Phuc
05/07/2025, 3:34 AMsimon.vergauwen
05/07/2025, 7:16 AMApplication
doesn't run inside a coroutine, but is a CoroutineScope
that has a SupervisorJob
. This Job
has an optional parent which can be supplied through embeddedServer
, but if using EngineMain
it's always null
.
The Routing
plugin has another CoroutineScope
which is a child of the Application
scope. Most engines don't run in a coroutine (except CIO), but they create a new coroutine for every request that is being handled.
So every coroutine that is created to handle a request is a grandchild of the Application
scope, and a child of the Routing
scope.
Depending on how you print the CoroutineContext
you will indeed always see the same thing. For Netty: https://github.com/ktorio/ktor/blob/828e6978166adf2ed73a01702d57958372d3dc4b/ktor-[…]er-netty/jvm/src/io/ktor/server/netty/NettyApplicationEngine.kte5l
05/07/2025, 7:23 AMHong Phuc
05/07/2025, 2:01 PMsimon.vergauwen
05/07/2025, 2:04 PMHong Phuc
05/07/2025, 2:12 PM