Skip to content

Commit dcd5ed3

Browse files
committed
Fix scala-js/scala-js#3393: Correctly report VM crashes as failed futures.
The line in this commit was supposed to complete the future with a failure if either `vmComplete` or `pipeResult` was failed, giving precedence to `vmComplete`. However that line was bogus, and would complete with a success if `pipeResult` was a success, even if `vmComplete` was a failure. This caused the `TestAdapter` to erroneously interpret a VM failure as a normal exit without spawning the testing interface bridge.
1 parent 5c9a28c commit dcd5ed3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

js-envs/src/main/scala/org/scalajs/jsenv/ExternalJSEnv.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,11 @@ abstract class ExternalJSEnv(
183183
case e => ioThreadEx = e
184184
}
185185

186-
// Chain Try's the other way: We want VM failure first, then IO failure
187-
promise.complete(pipeResult orElse vmComplete)
186+
/* We want the VM failure to take precedence if there was one,
187+
* otherwise the IO failure if there is one. We complete with a
188+
* successful () only when both vmComplete and pipeResult were successful.
189+
*/
190+
promise.complete(vmComplete.flatMap(_ => pipeResult))
188191
}
189192
}
190193

0 commit comments

Comments
 (0)