:wave: Hello! I have a NodeJS app running in Cloud...
# javascript
g
👋 Hello! I have a NodeJS app running in Cloud Run and am experimenting with
Throwable.stackTraceToString
but it's giving me only the generated Javascript source files, rather than the Kotlin ones (see 🧵). I did a bit of searching online but I'm not sure showing the Kotlin source files is even possible right now. Feels like a sourcemap issue to me. Is it possible to set this up so that the Kotlin sources are visible in the stacktrace?
✅ 1
I'm getting the following right now
Copy code
SignatureMismatch
   at SignatureMismatch_getInstance (/app/bin/thecodinglove-kmp-appBackend.js:71495:7)
   at $verifyRequestCOROUTINE$9.protoOf.qh (/app/bin/thecodinglove-kmp-appBackend.js:71714:32)
   at $computeCOROUTINE$<http://1.protoOf.ae|1.protoOf.ae> (/app/bin/thecodinglove-kmp-appBackend.js:14370:33)
   at $computeCOROUTINE$1.protoOf.v3 (/app/bin/thecodinglove-kmp-appBackend.js:14417:17)
   at CancellableContinuationImpl.protoOf.lp (/app/bin/thecodinglove-kmp-appBackend.js:20751:24)
   at ScheduledMessageQueue.protoOf.p11 (/app/bin/thecodinglove-kmp-appBackend.js:21534:19)
   at /app/bin/thecodinglove-kmp-appBackend.js:21459:14
   at processTicksAndRejections (node:internal/process/task_queues:78:11)
I would have expected to see the stacktrace reference this line where the exception is thrown
e
Do you see the source map files alongside the JS ones?
g
Here's the final binary folder which is packaged up as a docker container and uploaded. It looks like that .map file has mappings that point to Kotlin files - I'm assuming this is the right one?
e
Looks like it. That's strange tho, I would have expected to see a Kotlin file in the stack trace.
nod 1
g
Worth noting that I also have a multi-module setup and am using the npm.publish plugin to generate the combined binary in a single JS file
e
Try to change the source maps config to embed the Kotlin sources.
This should be done in the link task, not the compile task
g
Try to change the source maps config to embed the Kotlin sources.
Do you have an example of how to do that?
e
Yup but the task is something like
KotlinIrLink
. Not a the pc now so can't check.
g
Cool thanks, will try! 🙇 I'm also noticing that the .map file actually contains relative paths which is suspicious. Seeing a lot of
Copy code
./backend/slack-data/src/commonMain/kotlin/com/gchristov/thecodinglove/slackdata/usecase/SlackVerifyRequestUseCase.kt","../../../../.
a
unless you publish with your kotlin files, you won't be able to see the sources
e
Don't worry about paths. Just embed the entire sources.
g
Reading a bit more about source maps in NodeJS, it looks like I was missing the flag
--enable-source-maps
apparently. When I added this to my Docker command, I started getting the correct source path with no other changes.
CMD exec node --enable-source-maps thecodinglove-kmp-appBackend.js
👇
Copy code
Cancelled
   at Cancelled_getInstance (/app/bin/thecodinglove-kmp-appBackend.js:70582:7)
   at RealSlackAuthUseCase$invoke$slambda.protoOf.qh (/backend/slack-data/src/commonMain/kotlin/com/gchristov/thecodinglove/slackdata/usecase/SlackAuthUseCase.kt:33:20)
   at RealSlackAuthUseCase$invoke$slambda.protoOf.n5e (/app/bin/thecodinglove-kmp-appBackend.js:70628:16)
   at l (/app/bin/thecodinglove-kmp-appBackend.js:70749:16)
   at startUndispatchedOrReturn (/backend/appBackend/build/compileSync/js/main/productionLibrary/kotlin/src/kotlin/coroutines_13/IntrinsicsJs.kt:99:43)
   at withContext (/opt/teamcity-agent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/js/src/CoroutineContext.kt:61:5819)
   at RealSlackAuthUseCase.protoOf.v5d (/backend/slack-data/src/commonMain/kotlin/com/gchristov/thecodinglove/slackdata/usecase/SlackAuthUseCase.kt:29:88)
   at $handleHttpRequestAsyncCOROUTINE$0.protoOf.qh (/backend/slack/src/commonMain/kotlin/com/gchristov/thecodinglove/slack/SlackAuthHttpHandler.kt:46:16)
   at SlackAuthHttpHandler.protoOf.g5m (/app/bin/thecodinglove-kmp-appBackend.js:73847:16)
   at BaseHttpHandler$handleHttpRequest$slambda.protoOf.qh (/backend/common-service/src/commonMain/kotlin/com/gchristov/thecodinglove/commonservice/BaseHttpHandler.kt:55:17)
The error corresponds exactly to the line where the exception was thrown
e
Oh that's good to know! Thanks!
g
No worries! Glad it was as simple as that 🙂 Thanks for jumping in on this 🙌