microsoft / vscode-js-debug

A DAP-compatible JavaScript debugger. Used in VS Code, VS, + more
MIT License
1.67k stars 283 forks source link

module.register() will hang when debugging #2118

Closed millionkn closed 3 weeks ago

millionkn commented 3 weeks ago

My English is not very good, so I’m using ChatGPT for translation. I apologize for any formatting errors or other issues.

Describe the bug Debugging a JavaScript file which leverages module.register does end up in a infinite hang. This issue is the same asissue2009, which was closed due to lack of a reproduction method. I have found a stable way to reproduce the issue.

To Reproduce

//入口.js
import { register } from 'module'

console.log('print something');
register('anything') // hang up if has break point in this file
console.log('set break point here');
  1. In VS Code, set a breakpoint on line 6 of入口.js
  2. In the VS Code terminal (I'm using cmd), run node --inspect ./入口.js

Log File N/A

VS Code Version: 1.94.2

Additional context

The key to reproducing this issue is having Chinese characters in the file path of the file containing the breakpoint,However, it seems that the length of the Chinese characters matters. For example,if 入口.js is replaced with入.jsor口.js, it outputs nothing and simply exits.

If the filename is in another language, such as テスト.js (Japanese), it also outputs nothing.

I tested this on two versions of Node (v22.11.0 and v18.20.4), and the issue exists on both.

connor4312 commented 3 weeks ago

This is a result of https://github.com/nodejs/node/issues/50516