My js export classes started throwing exceptions, ...
# webassembly
r
My js export classes started throwing exceptions, after updating from Kotlin 2.1.10 to 2.1.20. But my question is - am I doing something wrong or is this the current state of the debugging experience? This is a nightmare to try to figure out what went wrong.
I am using export interfaces for Google Maps web: This piece of code suddenly started crashing:
Copy code
@JsName("google.maps.Map")
external class GMap(element: Element) {

}
It it directly caused by upgrading Kotlin from 2.1.10 to 2.1.20
a
@bashor @Ilya Goncharov [JB] ^^
b
@Rok Oblak could you please file an issue?
Could you please navigate to location on the top of stack (
composeApp.uninstantiated.mjs:5084
) and share what is there?
r
Yep will file an issue, thank you! here is the 5084th line:
Filed a ticket: CMP-8258 External class crashes with Kotlin version upgrade edit: I see it is filed under CMP, but that may not be the right place, let me know...
b
Thanks for the report, I think the issue should be moved to Kotlin project.
1
👍 1
Using CoroutineExceptionHandler may help you to get a proper exception, so you can put a breakpoint there or print a stacktrace, like below:
Copy code
val handler = CoroutineExceptionHandler { _, exception ->
    println("CoroutineExceptionHandler got ${exception.stackTraceToString()}")
}
r
Thanks Zalim, unfortunately no useful info is given - I tried adding these handlers in all my scopes but it did not catch the exception (it happens inside the composable, so I am not sure where to put it in that case. However I did put a try/catch inside the actual instance contruction of this javascript object (
Gmap(element)
) and that does successfully catch the exception, however it is non-informative:
console.js:36 JsException: Exception was thrown while running JavaScript code
b
@Rok Oblak thanks for the update, you can find one more trick to try in the issue
r
Thank you Zalim! I managed to resolve it after your suggestions. I had to use the file-level JsQualifier, and move the js(...) functions in a separate file.
🎉 1