How can I set a timeout for a specific request? A...
# ktor
c
How can I set a timeout for a specific request? A colleague of mine tried doing the request inside kotlinx.coroutine’s
withTimeout
function, but all hell broke loose. 😅
we get a very weird exception when doing a request inside `withTimeout`:
Copy code
kotlinx.serialization.SerializationException: Can't locate argument-less serializer for class kotlinx.coroutines.CoroutineScope
r
c
I figured out that the weird exception only happens if you request inside
withTimeout
and you’re using the “JsonFeature” on your client:
Copy code
val client = HttpClient(clientEngine) {
    install(JsonFeature) {
        serializer = KotlinxSerializer(Json)
    }
}
client.request(someHttpRequestBuilder) // exception, someone tried to serialize the coroutine itself
I’ll try to make a minimal project reproducing this problem and create a new issue