Skip to content

Exceptions escape and crash the entire jsEnv #47

Open
@japgolly

Description

@japgolly

It's perfectly, completely and deterministically reproducible in my private code that the new SJS 1.0 PhantomJs jsEnv doesn't catch exceptions in some cases. I haven't been able to work out what "some cases" means exactly. I've got code that looks something like this:

      def x(f: => Any) = try Right(f) catch { case e: Throwable => Left(e) }
      x(???)

and instead of the error my test is expecting being caught, it seems to be intercepted by PhantomJs and causes this:

scala.MatchError: 2 (of class java.lang.Byte)

  phantomjs://code/phantomjs-launcher8807894677851635821.js:8 in onError


  phantomjs://code/phantomjs-launcher8807894677851635821.js:10 in onError
  file:///tmp/tmp-9624954527195675435webapp-base-test-test-fastopt.js:396685 (in function "$p_jl_JSConsoleBasedPrintStream__doWriteLine__T__V")

  phantomjs://code/phantomjs-launcher8807894677851635821.js:12
[error] stack trace is suppressed; run last Test / testOnly for the full output
[error] (Test / testOnly) org.scalajs.testing.common.RPCCore$ClosedException: org.scalajs.testing.adapter.JSEnvRPC$RunTerminatedException
[error] Total time: 9 s, completed 9 Jun. 2020, 9:03:20 pm

We actually went over this ages ago in scala-js/scala-js#1555 and I came away with a local hack that avoided the problem for me consistently for years, until now.

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