nodejs / nodejs/node

Pause on uncaught exceptions stops at wrong position with ES modules

Open
#38,439 8 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

esm inspector
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

  • Version: 16.0.0
  • Platform: Win 10 x64
  • Subsystem: inspector
What steps will reproduce the bug?

Here's a repo with an easy reproduction:

  1. Open the repo in VS Code (or you can use another tool/any debugger)
  2. In the debug view (play button on the left hand side):
    • Check the [x] Uncaught Exceptions box in the breakpoints view.
    • Select "No Bug" and hit the play button. This runs no-bug/index.js.
  3. The debugger pauses at the location of the throw
  4. Now select "Repro Bug", and hit the play button. This runs bug/index.js: the same code in an ES module.
  5. The debugger pauses inside internal Node.js module code:

Under the hood this is just calling Debugger.setPauseOnExceptions({ state: 'uncaught' }), so it should be reproducable with any tool. In both cases this leads to a Debugger.pause, with the latter in the wrong location.

I'm guessing there's some inspector ✨magic that happens with commonjs that isn't happening for ES modules.

How often does it reproduce? Is there a required condition?

100%

What is the expected behavior?

In both cases, the debugger should pause on the throw

What do you see instead?

In ES modules, it pauses in module_job.js.

Additional information

This was originally reported in https://github.com/microsoft/vscode/issues/122246

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue from the linked node-38439 repository with the debugger's uncaught-exceptions setting, comparing no-bug/index.js with bug/index.js. Read the pause handling around module_job.js and the inspector entry points; done means ES modules pause at the throw location rather than inside internal module code.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.