https://kotlinlang.org logo
#ktor
Title
a

Andreas Scheja

01/03/2023, 9:32 AM
Hi, I was wondering if there is a special reason why the
ResponseSent
and
ReceiveRequestBytes
hooks don't have suspending handlers? At least the latter is given a
ByteReadChannel
so suspending calls should be quite common?
👀 1
a

Aleksei Tirman [JB]

01/03/2023, 1:27 PM
@e5l
e

e5l

01/03/2023, 1:31 PM
Hey @Andreas Scheja, thanks for the question. Could you tell me why do you need suspension in
ResponseSent
? As for
ReceiveRequestBytes
, we can add suspension there. I made a ticket: https://youtrack.jetbrains.com/issue/KTOR-5406/Add-suspend-modifier-to-ReceiveRequestBytes-hook
a

Andreas Scheja

01/03/2023, 3:27 PM
@e5l I have no use case where I would need it for
ResponseSent
right now, but is there a compelling reason not to change it? I mean if you want to call something suspending in there (and can't just
launch
it in a fire-and-forget manner) you have to bridge it with
runBlocking
, which would block the thread of the coroutine calling the hook -> not a good solution for a busy server.
5 Views