Operation is already in progress Exception
See original GitHub issueKtor Version
1.2.2
Ktor Engine Used(client or server and name)
Client Android
JVM Version, Operating System and Relevant Context
1.8, reproductible on a pure JVM project, and on a Android application consuming this JVM project.
Feedback
Stacktrace:
Exception in thread "Thread-3 @ktor-android-context#4" java.lang.IllegalStateException: Operation is already in progress
at kotlinx.coroutines.io.ByteBufferChannel.suspensionForSize(ByteBufferChannel.kt:2984)
at kotlinx.coroutines.io.ByteBufferChannel.access$suspensionForSize(ByteBufferChannel.kt:21)
at kotlinx.coroutines.io.ByteBufferChannel.readSuspendImpl(ByteBufferChannel.kt:2309)
at kotlinx.coroutines.io.ByteBufferChannel.readSuspend(ByteBufferChannel.kt:2249)
at kotlinx.coroutines.io.ByteBufferChannel.discardSuspend(ByteBufferChannel.kt:1723)
at kotlinx.coroutines.io.ByteBufferChannel.discard(ByteBufferChannel.kt:1707)
at kotlinx.coroutines.io.ByteReadChannelKt.discard(ByteReadChannel.kt:203)
at io.ktor.client.response.HttpResponse$close$1.invokeSuspend(HttpResponse.kt:71)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
How to reproduce:
runBlocking {
val client = HttpClient(Android) {
install(JsonFeature) {
serializer = KotlinxSerializer()
.also {
it.register(JsonArraySerializer)
}
}
}
repeat(100) {
try {
withTimeout(500) {
client.request<JsonArray>("https://jsonplaceholder.typicode.com/todos/") {
}
}
} catch (exception: TimeoutCancellationException) {
println(exception.message)
}
}
}
From what I understand, it seems like if the timeout cancellation happens during the json deserialisation phase of the request, we get the Operation is already in progress
exception. Because of that, it is not easy to reproduce: You might have to tweak the timeout value of 500
, or run the test multiple times, for the exception to appear.
Is there a workaround in the meantime ?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:5 (1 by maintainers)
Top Results From Across the Web
C# Winforms Npgsql 3.0.5 "An operation already in progress ...
database - C# Winforms Npgsql 3.0. 5 "An operation already in progress" error when trying to run multiple commands inside same connection -...
Read more >More detail on "Operation is already in progress" #1248 - GitHub
Then, if an "Operation is already in progress" is thrown, the exception could contain information about the ongoing operation.
Read more >Admin Operation Already in Progress - Copado Documentation
"Unknown Exception - Admin operation already in progress." Steps to reproduce: 1. Navigate to an Org Credential record.
Read more >apex - group membership operation already in progress
This error occurred: UNKNOWN_EXCEPTION: group membership operation already in progress. This is happening because the first step (assigning ...
Read more >CloudPoint policy continuously fails with "Operation already in ...
Problem. CloudPoint policy continuously fails with "Operation already in progress on asset <asset_id>". Error Message.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@e5l when is it supposed to be fixed? Or maybe there is some way to temporary work around the issue?
Yes indeed, I also found this commit which looks related. Just making sure 😃