Skip to content

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

@bcoe

Description

@bcoe
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.inspectorIssues and PRs related to the V8 inspector protocol

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions