-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Description
- 8.x+:
- All:
- inspector:
Background
Following up from #16531, for CommonJS modules we are now able to collect detailed coverage information regardless of how a process exits. This is facilitated by:
- starting a process with
--inspect-brk
. - running
startPreciseCoverage
. - waiting for the event
Runtime.executionContextDestroyed
(this will fire when the isolate terminates execution).
ESM Failing
Using the same approach outlined above for .mjs
files, the Runtime.executionContextDestroyed
event does not appear to fire -- I see the following output in a hung terminal:
Debugger listening on ws://127.0.0.1:53080/ce9cf16c-dce4-42b1-bf4f-98b523c9f36e
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
(node:93632) ExperimentalWarning: The ESM module loader is experimental.
Waiting for the debugger to disconnect...
Reproducing this Issue
I've been keeping the module c8 up to date, as we march towards a native test coverage solution. To see the bug in action, clone the above repo and run:
./bin/c8.js --experimental-modules test/fixtures/c.mjs
note that you can run:
./bin/c8.js test/fixtures/c.mjs
And the application will exit as expected (c.mjs isn't using import syntax, it seems to simply be the new importer that conflicts with the Runtime.executionContextDestroyed
event).