8000 Failing <project>/run can `close()` subsequent runs too early · Issue #4336 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content
Failing <project>/run can close() subsequent runs too early #4336
Closed
@gzm0

Description

@gzm0

How to reproduce: Add a line to HelloWorld#main that makes it fail (e.g. throw new Exception("foo")).

$ sbt
sbt:Scala.js> helloworld2_12/run
[info] Running helloworld.HelloWorld. Hit any key to interrupt.
scala-js/examples/helloworld/.2.12/target/scala-2.12/helloworld-fastopt/main.js:626
  throw $m_sjsr_package$().unwrapJavaScriptException__jl_Throwable__O($ct_jl_Exception__T__(new $c_jl_Exception(), "foo"))
  ^

java.lang.Exception: foo
    at ...
[error] org.scalajs.jsenv.ExternalJSRun$NonZeroExitException: exited with code 1
[error] 	at org.scalajs.jsenv.ExternalJSRun$$anon$1.run(ExternalJSRun.scala:186)
[error] (helloworld2_12 / Compile / run) org.scalajs.jsenv.ExternalJSRun$NonZeroExitException: exited with code 1
[error] Total time: 11 s, completed Dec 16, 2020, 8:46:05 PM
sbt:Scala.js> helloworld2_12/run
[info] Running helloworld.HelloWorld. Hit any key to interrupt.
[error] org.scalajs.jsenv.ExternalJSRun$ClosedException: Termination was requested by user
[error] 	at org.scalajs.jsenv.ExternalJSRun$$anon$1.run(ExternalJSRun.scala:184)
[error] (helloworld2_12 / Compile / run) org.scalajs.jsenv.ExternalJSRun$ClosedException: Termination was requested by user
[error] Total time: 1 s, completed Dec 16, 2020, 8:46:28 PM

This does not occur all the time (likely a race condition). The org.scalajs.jsenv.ExternalJSRun$ClosedException gets thrown if JSRun#close() is called before the JSEnv run terminates.

This is likely caused by close() here being called too early:

val run = jsEnv.start(input, config)
try {
readThread.start()
val fut = Future.firstCompletedOf(List(readPromise.future, run.future))
Await.result(fut, Duration.Inf)
} finally {
run.close()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug. Needs to be fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0