https://kotlinlang.org logo
#ktor
Title
# ktor
a

andylamax

10/18/2023, 4:43 PM
I am getting
Copy code
CoroutineContext.kt:32 Uncaught TypeError: context.we is not a function
    at CombinedContext.plus2 [as xe] (CoroutineContext.kt:32:21)
    at HttpClientEngineBase.kt:22:9
    at protoOf2.v2 (Lazy.kt:81:37)
    at protoOf.e1r (Lazy.kt:44:93)
    at HttpClient (HttpClient.kt:90:56)
    at HttpClient_init_$Init$ (HttpClient.kt:84:9)
    at HttpClient_init_$Create$ (HttpClient.kt:80:14)
    at HttpClient_0 (HttpClient.kt:43:18)
    at Object.scenes (index.kt:54:18)
    at sdk.ts:3:26
When I try to instantiate
HttpClient(Js)
on the browser. I have tried to recreate it in tests, but did not manage to reproduce. My hunch is DCE is a bit aggressive. Any one encouterd this?? Help!!
Update, disablling DCE, did not help either.
Copy code
tasks.withType<KotlinJsDce>().configureEach {
    enabled = false
}
I am beginning to think that this is not a ktor problem after all. After offering a different implementation that doesn't use ktor client, I got
Copy code
CoroutineScope.kt:277 Uncaught TypeError: context.wb is not a function
    at CoroutineScope_02 (CoroutineScope.kt:277:22)
    at new SnitchImpl (SnitchImpl.kt:20:17)
    at makeSnitch (SnitchConstructors.kt:10:24)
    at Object.scenes (sdk.index.kt:42:23)
    at sdk.ts:3:26
All these methods point to the plus operator for
CoroutineContext
. Somehow this is failing in a binary that has been marked by
binaries.library()
I have managed to narrow this down into a bug in the stdlib
Copy code
Uncaught TypeError: context.xe is not a function
    at CombinedContext.plus2 [as ye] (kotlin-kotlin-stdlib.js:254:21)
    at ktor-ktor-client-core.js:1547:33
    at protoOf2.v2 (kotlin-kotlin-stdlib.js:12322:42)
    at protoOf.j1r (ktor-ktor-client-core.js:1566:19)
    at HttpClient (ktor-ktor-client-core.js:545:33)
    at HttpClient_init_$Init$ (ktor-ktor-client-core.js:330:16)
    at HttpClient_init_$Create$ (ktor-ktor-client-core.js:335:12)
    at HttpClient_0 (ktor-ktor-client-core.js:629:18)
    at HttpClient_1 (ktor-ktor-client-core.js:5454:12)
    at Object.api (picapital-api-flix.js:168:16)
Moved this to https://kotlinlang.slack.com/archives/C7L3JB43G/p1697708746620059 as it appears to not be related to ktor but the compiler or the kotlin-stdlib