I'm facing a problem with updating to Kotlin 2.1.0...
# webassembly
p
I'm facing a problem with updating to Kotlin 2.1.0 and kotest to 6.0.0.M1, see the PR: https://github.com/krzema12/snakeyaml-engine-kmp/pull/231. The error occurs while running wasmJs tests:
Copy code
> Task :wasmJsBrowserTest
Disconnected (0 times) , because no message in 30000 ms.
java.lang.IllegalStateException: command '/home/runner/.gradle/nodejs/node-v22.0.0-linux-x64/bin/node' exited with errors (exit code: 1)
I imagine the reason can be anything that causes Node to hang. I found two threads with the similar symptom: • https://kotlinlang.slack.com/archives/CDFP59223/p1722954099001579?thread_ts=1722925272.045489&cid=CDFP59223 it was something about Compose, and I don't use Compose • https://kotlinlang.slack.com/archives/CDFP59223/p1717026550065119 - some custom Karma config helped there - it didn't in case of this problem How can I troubleshoot it? Is it a known issue?
p
Tried it, but the tests still fail, and I don't see anything new in the logs: https://github.com/krzema12/snakeyaml-engine-kmp/actions/runs/12471901619/job/34809717697?pr=231
Maybe I didn't apply the config correctly? Could you verify?
is there a YouTrack issue to track adding better error reporting without such customizations?
o
Maybe I didn't apply the config correctly? Could you verify?
Looks correct to me. Would you like to try to update the Kotlin and Kotest versions separately if it's possible? Maybe it would become clear where to report the problem? Do you have the same issue locally or only on the CI?
is there a YouTrack issue to track adding better error reporting without such customizations?
Afaik, the error we see is reported by karma, not by Kotlin. _ Increasing the timeout didn't help in our case, but some people say it helped them: https://stackoverflow.com/questions/54744584/karma-disconnected-because-no-message-in-10000-ms
p
I tried updating separately and it doesn't work - both seem to be interconnected. Locally it works fine, so the problem manifests itself only on CI.
o
Do you use any docker container? Or run simply on github agent?
p
Directly on GitHub Actions runner, no Docker
👍 1
What's weird is that it's a really simple project and test, I'm wondering how it works for more complex ones
Plus, this issue manifests upon updating, so looks like a regression?
Sorry, I'm mixing up two issues with wasm tests in two projects - the other one is simple, and this one is more complex
My ideas for the next steps is to check what changed in the Wasm bundle used in the tests and how/if the test runner's version changed
o
I see that karma version got updated: https://github.com/krzema12/snakeyaml-engine-kmp/pull/231/files#diff-efb63acf9a72b6b070ee7035c8ecb3a65f1f21f991717b6c3d4f8e9d30d7c9e5R1111 It's brought by a newer Kotlin, I guess. It could be a reason. But I'm not familiar with how to override the version. Most of the colleagues are already on holidays. cc: @Ilya Goncharov [JB] could you please have a look here when you can? Can we override karma version provided by Kotlin?
👍 1
p
Karma version is defined here and used here - it seems to be hardcoded, I haven't found a way to customize it. I'll try overriding the version in the lockfile and somehow disabling lockfile validation, but not sure how to do it yet
> Most of the colleagues are already on holidays. it certainly can wait for until Christmas, no worries 🙂
o
I am having the same problem. Locally in the browser's console, I can see
Uncaught (in promise) WebAssembly.Exception {  }
without any stack trace (screenshot from Chrome is attached). Also, I see
404: /absolute/tmp/_karma_webpack_617759/json-schema-validator-root-json-schema-validator-wasm-js-test.wasm.map
message in the console (but I can see that file in the build directory for the wasmJs target). I am not sure if it is connected to the problem, but I don't see this message when running tests on 2.0.21
i
Can we override karma version provided by Kotlin?
Yes, it is possible.
Copy code
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
    rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().versions.karma.version = "..."
}
o
Thank you, @Ilya Goncharov [JB] for suggestion. Tried changing the karma version to the previous (6.4.3) one but it didn’t help, unfortunately - same error happens when using the old version
i
Thanks for checking. I have investigated the case locally, and looks I found the root cause. The problem in linkage of coroutines 1.8.0 (which was built against Kotlin/Wasm 1.9.21) with Kotlin stdlib 2.1.0. In 2.1.0 we have some changes in our linkage process (including changes in stdlib), so I’d recommend to use new Kotlin coroutines which was built with Kotlin 2.1.0 For example the latest one with version 1.10.1
p
I tried downgrading Karma as well, and it doesn't work (logs). I don't think the version of coroutines are relevant here. Could you check what's wrong with my project (the original question in this thread)?
i
@Piotr Krzemiński Have you checked the project with upgraded coroutines yet?
o
I tried that on my project locally - it worked like a charm!
Copy code
commonTest {
  dependencies {
    //....
    runtimeOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
  }
}
I will push changes and see if it also works on GitHub runner. Thank you very much, @Ilya Goncharov [JB]! BTW: if you have some time, could you share details about how you discovered that the problem was related to the linkage process? Maybe some resources to read - I honestly have no idea what could be done with errors like that... Once again, thank you very much!
p
@Ilya Goncharov [JB] I used a similar workaround like @Oleg Smirnov suggested above, and apparently coroutines are used transitively because it works fine so far! (3 CI runs are green). I'm also curious about your approach here, and I'm wondering if there should be a better error message, preferably in compile time, to catch these
FWIW, kotest 6.0.0.M1 includes old coroutines 1.8.0 (from Feb 2024) here
i
Don’t you think that it is better to use
coroutines
for
main
source set as well and not just
runtime
but honest
implementation
dependency? As for error message, surely it is the problem of the Kotlin/Wasm (I don’t understand if it is a tooling’s bug or compiler’s one). As for diagnostic, I run test in “debug” mode. I changed
singleRun
onto
false
in
karma.config.js
(
build/js/<package-name>-test
) And browser to
Chrome
instead of
ChromeHeadless
. It runs test in prepared
Chrome
browser, and you can debug it right in browser. And I debugged
wasm
file (Chrome debug has checkbox “Pause on uncaught exceptions”). It helps to find what exception was thrown. And actually there were changes with browser API in stdlib.
👍 2
Don’t you think that it is better to use
coroutines
for
main
source set
e.g. in my case, coroutines are used only in tests, so I don't see a reason to add a production dependency on them
👍 1