-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exceptions escape and crash the entire jsEnv #47
Comments
The fix is super easy so I've raised #48 . |
For reference: the fix I used to have is: class PhantomJS2Env(c: PhantomJSEnv.Config) extends PhantomJSEnv(c) {
override protected def vmName: String = "PhantomJS2"
private val consoleNuker = new MemVirtualJSFile("consoleNuker.js")
.withContent("console.error = console.log;")
override protected def customInitFiles(): Seq[VirtualJSFile] =
super.customInitFiles() :+ consoleNuker
} which doesn't work anymore because |
The workaround could now be written as: final class PhantomJS2Env(config: PhantomJSEnv.Config) extends JSEnv {
private val innerEnv = new PhantomJSEnv(c)
val name: String = "PhantomJS2"
private val consoleNuker: Input = {
val p = Files.write(
Jimfs.newFileSystem().getPath("consoleNuker.js"),
"console.error = console.log;".getBytes(StandardCharsets.UTF_8))
Input.Script(p)
}
def start(input: Seq[Input], config: RunConfig): JSRun =
innerEnv.start(consoleNuker :: input, config)
def startWithCom(input: Seq[Input], config: RunConfig,
onMessage: String => Unit): JSComRun =
innerEnv.startWithCom(consoleNuker :: input, config, onMessage)
} |
Oh wow thanks @gzm0 ! I didn't think of doing that. Actually I came up with my own hack too :) project/phantomjs-fix.js console.error = console.log; and then Test / jsEnvInput := Input.Script(((ThisBuild / baseDirectory).value / "project/phantomjs-fix.js").toPath) +: (Test / jsEnvInput).value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
and instead of the error my test is expecting being caught, it seems to be intercepted by PhantomJs and causes this:
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.
The text was updated successfully, but these errors were encountered: