Pause on uncaught exceptions stops at wrong position with ES modules
Nobody has claimed this yet.
- 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:
- Open the repo in VS Code (or you can use another tool/any debugger)
- In the debug view (play button on the left hand side):
- Check the
[x] Uncaught Exceptionsbox in the breakpoints view. - Select "No Bug" and hit the play button. This runs
no-bug/index.js.
- Check the
- The debugger pauses at the location of the
throw - Now select "Repro Bug", and hit the play button. This runs
bug/index.js: the same code in an ES module. - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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