NODE_V8_COVERAGE not output when Error thrown during initialization

  • Version: 12.0.0 -> 12.9.1.
  • Platform: OSX
  • Subsystem: coverage/process

Sometime between node@v11.15.0 and node@12.0.0 , NODE_V8_COVERAGE seems to have stopped outputting if a script throws in the first tick, as an example:

throw Error('error');
if (true) {
  console.info('hello world');
} else {
  console.info('goodnight moon');
}

This script will output coverage:

process.exit(1);
if (true) {
  console.info('hello world');
} else {
  console.info('goodnight moon');
}

I've noticed, similarly, that prepareStackTrace appears to not be called, which is why I'm using timeouts in the tests here; I wonder if the root cause might be the same.

CC: @addaleax, @joyeecheung, @devsnek, @nodejs/testing