Trying to migrate from ktor 1.5.3 to 1.6.0 in my m...
# ktor
a
Trying to migrate from ktor 1.5.3 to 1.6.0 in my multiplatform project, but got a freeze exception, when initialise HttpClient. I found that there is already known issue with HashMaps (https://github.com/Kotlin/kotlinx.serialization/issues/1450) but looks like it is not my case. There is my stack trace:
Copy code
Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlinx.coroutines.JobImpl@2516528
    at 0   DriversAppApi                       0x000000010155103f kfun:kotlin.Throwable#<init>(kotlin.String?){} + 95 (/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/Throwable.kt:23:37)
    at 1   DriversAppApi                       0x00000001015497ad kfun:kotlin.Exception#<init>(kotlin.String?){} + 93 (/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
    at 2   DriversAppApi                       0x0000000101549a1d kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 93 (/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
    at 3   DriversAppApi                       0x00000001015819fd kfun:kotlin.native.concurrent.InvalidMutabilityException#<init>(kotlin.String){} + 93 (/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt:22:60)
    at 4   DriversAppApi                       0x0000000101581dcf ThrowInvalidMutabilityException + 431 (/Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:93:11)
    at 5   DriversAppApi                       0x00000001016e5b50 MutationCheck + 128
    at 6   DriversAppApi                       0x00000001017ebda6 kfun:kotlinx.coroutines.JobImpl#<init>(kotlinx.coroutines.Job?){} + 150 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/JobSupport.kt:1328:46)
    at 7   DriversAppApi                       0x00000001017d692c kfun:kotlinx.coroutines#Job(kotlinx.coroutines.Job?){}kotlinx.coroutines.CompletableJob + 188 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/Job.kt:379:55)
    at 8   DriversAppApi                       0x00000001019f9254 kfun:io.ktor.client.HttpClient#<init>(io.ktor.client.engine.HttpClientEngine;io.ktor.client.HttpClientConfig<out|io.ktor.client.engine.HttpClientEngineConfig>){} + 1796 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-core/common/src/io/ktor/client/HttpClient.kt:87:45)
    at 9   DriversAppApi                       0x00000001019fa310 kfun:io.ktor.client.HttpClient#<init>(io.ktor.client.engine.HttpClientEngine;io.ktor.client.HttpClientConfig<out|io.ktor.client.engine.HttpClientEngineConfig>;kotlin.Boolean){} + 144 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-core/common/src/io/ktor/client/HttpClient.kt:81:9)
    at 10  DriversAppApi                       0x00000001019f8ad5 kfun:io.ktor.client#HttpClient(io.ktor.client.engine.HttpClientEngine;kotlin.Function1<io.ktor.client.HttpClientConfig<*>,kotlin.Unit>){}io.ktor.client.HttpClient + 517 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-core/common/src/io/ktor/client/HttpClient.kt:62:17)
    at 11  DriversAppApi                       0x00000001011b389d kfun:com.arrival.adp.drivers.app.api.rest.HttpClientFactory#create(){}io.ktor.client.HttpClient + 285 (/Users/alexander.ivanov/Development/pmob-sdrv-graphql-api-tool/sources/drivers-app-api/src/commonMain/kotlin/com/arrival/adp/drivers/app/api/rest/HttpClientFactory.kt:31:16)
My version changes: kotlin:
1.4.32
->
1.5.10
Ktor:
1.5.3
->
1.6.0
kotlinx.coroutines:
1.4.3-native-mt
->
1.5.0-native-mt
kotlinx.serialization:
1.1.0
->
1.2.1
Does somebody faced this issue?
a
Could you please file an issue in YouTrack https://youtrack.jetbrains.com/newIssue?project=KTOR with a sample code for reproduction attached?
a
Yes, At this moment I’m trying to reproduce issue in demo project.
It looks like I found the reason. It is because of apollo library included in project. When I removed apollo from project the problem is gone.
@mbonnin Hi, Does apollo graphql library includes coroutines? If so which version?
👋 1
m
Yes it does. The specific version depends the apollo-android version but it's not the
native-mt
one
You can get it with
./gradlew dependencies
, that should show all the transitives dependencies and how they are resolved
a
Let me try, thank you
👍 1
Yes, it helps. 🎉 Thanks again.
🎉 1