nodejs / nodejs/node

Synchronous exceptions in ES modules are always 'caught'

Aperta
#50,430 9 commenti 11 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

confirmed-bug esm inspector v8 engine
Lingua principale
JavaScript
Stelle
122k
Fork
37.3k
Merge medio
4g 2h
PR unite (30g)
283

Descrizione

Version

20.3.1

Platform

Darwin mbp.peet.io 22.6.0 Darwin Kernel Version 22.6.0: Fri Sep 15 13:39:52 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_X86_64 x86_64

Subsystem

inspector

What steps will reproduce the bug?
  1. Start a program containing throw new Error('foo'); in an ES module
  2. Attach a debugger, like devtools or VS Code's debugger, and enable "pause on uncaught exceptions"
  3. Run the program
How often does it reproduce? Is there a required condition?

100%

What is the expected behavior? Why is that the expected behavior?

The runtime should pause on the throw line

What do you see instead?

The runtime does not pause and the program exits

Additional information

First reported in https://github.com/microsoft/vscode-js-debug/issues/1861

Guessing this is because module evaluation is in a try/catch. Wonder if there's any machinery that can be used to mark containing exceptions as uncaught

https://github.com/nodejs/node/blob/0a0b8dfd0d3684d6602599e1f0d9d935b3758700/lib/internal/modules/esm/module_job.js#L217-L219

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia da lib/internal/modules/esm/module_job.js intorno alle righe 217-219 e riproduci il problema usando un modulo ES contenente un throw sincrono con un debugger collegato. Traccia il modo in cui l’inspector gestisce l’eccezione durante la valutazione del modulo; il lavoro è completato quando il debugger si interrompe sul throw con pause on uncaught exceptions abilitato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.