worker_threads that use es modules incorrectly pause when loaded
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
- 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:
- Open the folder in VS Code
- 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. - A worker thread spawns, logs its message, and exits
- Now select "Bug", and hit the play button. This runs
bug/index.js: the same code in an ES module. - 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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere das Problem mit bug/index.js und no-bug/index.js unter dem Node.js-Debugger von VS Code. Beginne damit, das Verhalten von ES-module- und non-module-Workern rund um den Aufruf inspector.waitForDebugger() und den verknüpften VS Code bootloader zu vergleichen. Die Aufgabe ist abgeschlossen, wenn der Debugger im ES-module-Fall nicht mehr in der ersten Zeile des Workers anhält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, nodejs
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100