I’m seeing some weird behavior where I use a ktor ...
# ktor
d
I’m seeing some weird behavior where I use a ktor client within a
withContext
block and the request succeeds but the withContext never hangs. like, i have:
Copy code
log.info("going to execute request $callsite")
withContext(MyContextThingy()) {
 log.info("in first context")
}
log.info("back from context")
val res: HttpResponse = withContext(MyContextThingy()) {
 log.info("top of context")
 val response: HttpResponse = httpClient.request {
  url.takeFrom(this@DruidClient.url)
  method = HttpMethod.Post
  contentType(ContentType.Application.Json)
  body = req
 }
 log.info("after request")
 response
}
log.info("after WC")
res
and it gets in and out of the first withContext fine, and logs
after request
, but never
after WC
. anyone seen anything odd like this?
this is being run from within ktor-server, if that makes a different
i guess withContext does scoping, so maybe my ktor-client is leaking a job?
is it because i’m not calling receive() on the response?
ah got it. yeah, if we create a response and don’t receive it, you better not try to end a coroutine scope