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
<http://log.info|log.info>("going to execute request $callsite")
withContext(MyContextThingy()) {
 <http://log.info|log.info>("in first context")
}
<http://log.info|log.info>("back from context")
val res: HttpResponse = withContext(MyContextThingy()) {
 <http://log.info|log.info>("top of context")
 val response: HttpResponse = httpClient.request {
  url.takeFrom(this@DruidClient.url)
  method = <http://HttpMethod.Post|HttpMethod.Post>
  contentType(ContentType.Application.Json)
  body = req
 }
 <http://log.info|log.info>("after request")
 response
}
<http://log.info|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