nodejs / nodejs/node

worker_threads that use es modules incorrectly pause when loaded

Aperta
#38,420 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

esm inspector worker
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?

It's easiest to run under a debugger that supports worker threads, like VS Code's Node.js debugger. I've created an example repo here:

  1. Open the folder in VS Code
  2. In the debug view (play button on the left hand side), select "No Bug" and hit the play button. This runs no-bug/index.js.
  3. A worker thread spawns, logs its message, and exits
  4. Now select "Bug", and hit the play button. This runs bug/index.js: the same code in an ES module.
  5. The debugger pauses on the first line in the worker
How often does it reproduce? Is there a required condition?

100%

What is the expected behavior?

The debugger doesn't pause with ES modules

What do you see instead?

The debugger pauses

Additional information

It looks like Node.js is incorrectly reporting that the program is started with inspectBrk:

VS Code (and Webstorm I think, though I haven't tried to repro there) use a bootloader to inject ourselves into the process via NODE_OPTIONS. We don't actually invoke with --inspect-brk, we manually call inspector.waitForDebugger(). I'm guessing this triggers inspectBrk to be true, but I haven't debugged into it that far.

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

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

Riproduci il problema con bug/index.js e no-bug/index.js usando il debugger Node.js di VS Code. Inizia confrontando il comportamento dei worker ES-module e non-module in relazione alla chiamata inspector.waitForDebugger() e al VS Code bootloader collegato. Il lavoro è completato quando il debugger non si ferma più sulla prima riga del worker nel caso ES-module.

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
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.