Skip to content
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

bug: Runtime.executionContextDestroyed event does not fire for .mjs files #17336

Closed
bcoe opened this issue Nov 27, 2017 · 1 comment
Closed
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. inspector Issues and PRs related to the V8 inspector protocol

Comments

@bcoe
Copy link
Contributor

bcoe commented Nov 27, 2017

  • 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:

  1. starting a process with --inspect-brk.
  2. running startPreciseCoverage.
  3. 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).

CC: @bmeck, @ak239, @schuay, @hashseed

@addaleax addaleax added esm Issues and PRs related to the ECMAScript Modules implementation. inspector Issues and PRs related to the V8 inspector protocol labels Nov 27, 2017
@TimothyGu
Copy link
Member

This bug isn't actually in the ESM loading system but in c8, since the .mjs file actually goes through the regular CJS loading process due to a lack of --experimental-modules. I've filed a PR that fixes this issue in c8 at bcoe/c8#6.

However, that PR doesn't make ESM just start working in c8 because of a separate bug in Node.js, which I've filed at #17340.

I will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

No branches or pull requests

3 participants