Pause on uncaught exceptions stops at wrong position with ES modules
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.3k
- Merge medio
- 4g 2h
- PR unite (30g)
- 283
Descrizione
- 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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo il problema dal repository collegato node-38439 con l'impostazione del debugger per le eccezioni non catturate, confrontando no-bug/index.js con bug/index.js. Leggi la gestione della pausa attorno a module_job.js e i punti di ingresso dell'inspector; il lavoro è completato quando i moduli ES si fermano nel punto del throw invece che all'interno del codice dei moduli interni.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, nodejs
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 52/100