I updated from KTOR 2.1.2 to 2.2.2 and started to ...
# ktor
c
I updated from KTOR 2.1.2 to 2.2.2 and started to receive
GZIP magic invalid
errors pretty much straight away. Does anyone have any tipps? Not much on Google besides a old KTOR ticket from 2020. I’m using KTOR on Android with the OkHttp enging
Copy code
java.lang.IllegalStateException: GZIP magic invalid: 958
	at java.lang.reflect.Constructor.newInstance0(Native Method)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
	at io.ktor.utils.io.ExceptionUtilsJvmKt$createConstructor$$inlined$safeCtor$1.invoke(ExceptionUtilsJvm.kt:3)
	at io.ktor.utils.io.ExceptionUtilsJvmKt$createConstructor$$inlined$safeCtor$1.invoke(ExceptionUtilsJvm.kt:1)
	at io.ktor.utils.io.ExceptionUtilsJvmKt.tryCopyException(ExceptionUtilsJvm.kt:77)
	at io.ktor.utils.io.ByteBufferChannelKt.rethrowClosed(ByteBufferChannel.kt:1)
	at io.ktor.utils.io.ByteBufferChannelKt.access$rethrowClosed(ByteBufferChannel.kt:1)
	at io.ktor.utils.io.ByteBufferChannel.setupStateForRead(ByteBufferChannel.kt:39)
	at io.ktor.utils.io.ByteBufferChannel.readAsMuchAsPossible(ByteBufferChannel.kt:34)
	at io.ktor.utils.io.ByteBufferChannel.readAvailable$suspendImpl(ByteBufferChannel.kt:1)
	at io.ktor.utils.io.ByteBufferChannel.readAvailable(ByteBufferChannel.kt:3)
	at io.ktor.utils.io.jvm.javaio.InputAdapter$loop$1.loop(Blocking.kt:126)
	at io.ktor.utils.io.jvm.javaio.InputAdapter$loop$1$loop$1.invokeSuspend(Blocking.kt:12)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:12)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:119)
	at io.ktor.utils.io.jvm.javaio.UnsafeBlockingTrampoline.dispatch(Blocking.kt:11)
	at kotlinx.coroutines.internal.DispatchedContinuation.resumeWith(DispatchedContinuation.kt:28)
	at io.ktor.utils.io.jvm.javaio.BlockingAdapter.submitAndAwait(Blocking.kt:16)
	at io.ktor.utils.io.jvm.javaio.BlockingAdapter.submitAndAwait(Blocking.kt:3)
	at io.ktor.utils.io.jvm.javaio.InputAdapter.read(Blocking.kt:6)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:248)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:267)
	// my app stack
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:12)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:119)
	at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:13)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:3)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:1)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:15)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:29)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:1)
Caused by: java.lang.IllegalStateException: GZIP magic invalid: 958
	at io.ktor.util.EncodersJvmKt$inflate$1.invokeSuspend(EncodersJvm.kt:666)
	at io.ktor.util.EncodersJvmKt$inflate$1.invoke(EncodersJvm.kt:1)
	at io.ktor.util.EncodersJvmKt$inflate$1.invoke(EncodersJvm.kt:2)
	at io.ktor.utis.io.CoroutinesKt$launchChannel$job$1.invokeSuspend(Coroutines.kt:68)
	... 8 more
Seems like this happens when using Gzip, HttpCache and Logging with the
INFO
or
HEADERS
log levels. Removing one of the three solves the issue