Testing 2.3.0-Beta2 and I have a strange issue on ...
# eap
r
Testing 2.3.0-Beta2 and I have a strange issue on K/JS target. At first sight it looks like a typical problem with incremental compilation - the project works fine on fresh build and after some code change in dev mode I'm seeing
TypeError: callAgent.jsonRpcCall_ij3z26_k$ is not a function
error. But it's not so simple. More in thread.
youtrack new 1
First of all - using
kotlin.incremental=false
and
kotlin.incremental.js=false
doesn't fix the issue.
Second - stopping dev server, making
clean
and running dev mode again doesn't fix the issue as well - the error is immediately visible again (even without any other code change).
The only way to "reset" the problem is running clean build with disabled Gradle cache (org.gradle.caching=false). But even with this option, the project is broken again after any other code change.
So far I can't reproduce the issue with a simple project but I'll keep trying.
There is no issue with Kotlin 2.2.21.
t
cc @Artem Kobzar
a
@Robert Jaros as soon as you find something, please let us know. Also, could you please share the settings for the compiler: target, module system, experimental language features enabled, etc
r
Nothing specific yet. The project is a Kilua fullstack application. Frontend targets
js
+
wasmJs
(code is in the
webMain
source set). I'm using
useEsModules()
and
target.set("es2015")
options. The
kotlin.time.ExperimentalTime
and
kotlin.js.ExperimentalWasmJsInterop
opt-ins are enabled by the gradle plugin. Compose compiler is enabled.
Simplified architecture:
APP -> LIB1 -> LIB2
. The problematic
CallAgent()
class is defined inside LIB2. The generated .mjs file for LIB2 seems stable and correct. The class is used inside LIB1. The generated .mjs file for LIB1 is correct on initial build. It looks like this:
Copy code
var callAgent = CallAgent.new_dev_kilua_rpc_CallAgent_uqx5si_k$();
  var tmp_5 = callAgent.jsonRpcCall_psige4_k$(url, tmp_3, method, tmp_4, $completion);
After code change inside APP (only some specific files, which reference LIB1) at least one of the generated .mjs files for LIB1 is different and incorrect:
Copy code
var callAgent = CallAgent.new_dev_kilua_rpc_CallAgent_uqx5si_k$();
  var tmp_5 = callAgent.jsonRpcCall_ij3z26_k$(url, tmp_3, method, tmp_4, $completion);
The method name is different and results in TypeError.
I've experimented a bit, tried inheriting from the class, inlining functions but so far no luck - it's always the same error (the incorrect method name is always the same).
At the same time I can use
CallAgent()
class directly from APP and call this problematic method without issues.
What puzzles me at the moment is why this mjs file generated from the library can be different at all?
I can workaround the problem by copying the
CallAgent
class from LIB2 to LIB1, so it seems to be some kind of a problem with nested dependencies and not the code itself.
a
@Robert Jaros thank you so much for sharing it. I believe it's enough for the issue description. May I ask you to create a ticket on YouTrack so I will play around with it today?
r
I think I've managed to create a reproducer. I'm filling an issue.
a
It's brilliant, thank you @Robert Jaros. I will start work on it today!
thank you color 1
a
@Robert Jaros thank you so much for sharing the issue. The issue was in IC after my fix for generator based coroutines. I've just merged the fix and it should be available in 2.3.0-RC. Until this, may I ask you to test it on your side with the dev version containing the fix? The KGP version is 2.3.0-RC-214, and there should be a new repo added to the maven repository list: https://packages.jetbrains.team/maven/p/kt/dev/ .
r
I'll test later today
thank you color 1
The fix works for both the reproducer example and my original project. Great work! Thank you.
glory 1