Skip to content

Stack trace filenames are different when running from SBT #20

Open
@armanbilge

Description

@armanbilge

Cats Effect isn't strictly necessary for a minimization, but here it helps demonstrate how this issue affects published source maps.

// build.sbt
scalaVersion := "2.13.7"
scalaJSUseMainModuleInitializer := true
libraryDependencies += "org.typelevel" %%% "cats-effect" % "3.2.9"
enablePlugins(ScalaJSPlugin)

// project/plugins.sbt
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1")

// src/main/scala/Example.scala
import cats.effect.{IO, IOApp}

object Example extends IOApp.Simple {
  override def run: IO[Unit] = IO.raiseError(new Throwable("Boom!"))
}

Running within sbt I get:

java.lang.Throwable: Boom!
    at $c_LExample$.run__Lcats_effect_IO (/workspace/example/target/scala-2.13/example-fastopt/file:/workspace/example/src/main/scala/Example.scala:4:46)
    at $f_Lcats_effect_IOApp__main__AT__V (/workspace/example/target/scala-2.13/example-fastopt/https:/raw.githubusercontent.com/typelevel/cats-effect/v3.2.9/core/js/src/main/scala/cats/effect/IOApp.scala:267:55)
    at $s_LExample__main__AT__V (/workspace/example/target/scala-2.13/example-fastopt/file:/workspace/example/src/main/scala/Example.scala:3:8)
    at /workspace/example/target/scala-2.13/example-fastopt/main.js:43393:1
    at /workspace/example/target/scala-2.13/example-fastopt/main.js:43394:4
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:305:38)
    at [stdin]:8:25
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:305:38)

Notice how the filenames are prepended with my workspace and also the URL has lost a slash. If I run directly with node --enable-source-maps I get:

<ref *1> /workspace/example/src/main/scala/Example.scala:4
  override def run: IO[Unit] = IO.raiseError(new Throwable("Boom!"))
                                             ^

java.lang.Throwable: Boom!
    at $c_LExample$.run__Lcats_effect_IO (/workspace/example/src/main/scala/Example.scala:4:46)
    at null.$f_Lcats_effect_IOApp__main__AT__V (https://raw.githubusercontent.com/typelevel/cats-effect/v3.2.9/core/js/src/main/scala/cats/effect/IOApp.scala:267:55)
    at null.$s_LExample__main__AT__V (/workspace/example/src/main/scala/Example.scala:3:8)
    at Object.<anonymous> (/workspace/example/target/scala-2.13/example-fastopt/main.js:43393:1)
    at Object.<anonymous> (/workspace/example/target/scala-2.13/example-fastopt/main.js:43394:4)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  jl_Throwable__f_s: 'Boom!',
  jl_Throwable__f_e: null,
  jl_Throwable__f_enableSuppression: true,
  jl_Throwable__f_writableStackTrace: true,
  jl_Throwable__f_stackTraceStateInternal: [Circular *1],
  jl_Throwable__f_stackTrace: null,
  jl_Throwable__f_suppressed: null
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions