any tips on how to debug this? it's a class cast ...
# javascript
b
any tips on how to debug this? it's a class cast exception inside a coroutine that I have no clue how to debug; coroutines in general seem to rewrite the code in such a fashion that I can not find the originating issue Edit: I placed the following thing into webpack.config.d:
Copy code
config["mode"] = 'development'
1
e
Just wondering how that config change made it work tho...
b
I was able to somehow figure out where the exception was thrown
e
Ah, so basically you got cleaner code spit out
b
yeah, debugging class cast exceptions seems incredibly bad
the minified code is basically unreadable
e
Agree. Was that your own issue or from the library?
b
library had type comments that said: returns Promise<Class>
I typed it as such and had a cast as well on a more specific class
turns out it returns Type | undefined (in certain cases)
e
Ahhh ok. Seems like something that tend to happen when interoping with JS libs.
b
I'm contemplating actually shipping unminified code to production because of that
1.6mb right now vs 160kb minified
e
I try to avoid JS dependencies as much as possible. If you can rewrite it in Kotlin without spending days on it, I'd go for it.
b
same here, but the thing I'm interacting with is a framework
think of it as something similar to Django but in JS
e
Ok then you're stuck with it. Typings are difficult to get right unfortunately.
b
yeah, basically
TS type definitions would have had the same issue and the ones I was using have been unmaintained for 2 years; it's just the class cast exceptions + coroutine continuations that really cause me grief
t
config["mode"] = 'development'
You can do it from Gradle DSL too
Also you can add special exception handler for coroutines. It's WA for https://github.com/Kotlin/kotlinx.coroutines/issues/3978