https://kotlinlang.org logo
Title
c

Cristián Arenas

01/28/2020, 11:41 PM
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`:
kotlinx.serialization.SerializationException: Can't locate argument-less serializer for class kotlinx.coroutines.CoroutineScope
r

rocketraman

01/29/2020, 5:21 AM
c

Cristián Arenas

01/29/2020, 2:30 PM
I figured out that the weird exception only happens if you request inside
withTimeout
and you’re using the “JsonFeature” on your client:
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