Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module.register() will hang when debugging #2009

Closed
mxschmitt opened this issue May 13, 2024 · 5 comments
Closed

module.register() will hang when debugging #2009

mxschmitt opened this issue May 13, 2024 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@mxschmitt
Copy link
Member

mxschmitt commented May 13, 2024

Describe the bug

Debugging a JavaScript file which leverages module.register does end up in a infinite hang.

To Reproduce

// loader.js
module.exports = {
  initialize: ({ number, port }) => {
    port.postMessage(`increment: ${number + 1}`)
  }
}
// test.js
const { pathToFileURL } = require('url');
const { port1, port2 } = new MessageChannel();

port1.on('message', (msg) => {
  console.log(msg);
});
port1.unref()

console.log('before')
require('node:module').register(pathToFileURL(require.resolve('./loader.js')), {
  parentURL: pathToFileURL(__filename),
  data: {
    number: 1,
    port: port2
  },
  transferList: [port2],
});
console.log('after')

(following their example)

Steps to reproduce the behavior:

  1. node test.js

Log File

N/A

VS Code Version: 1.90.0

Additional context

Looks like fixed in VSCode insiders - wasn't able to reproduce it there.

Version: 1.90.0-insider (Universal)
Commit: 26c4a07b47a2bd34480a5e4cba2c2384c590b039
Date: 2024-05-10T18:24:30.982Z
Electron: 29.3.1
ElectronBuildId: 9464424
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin arm64 23.4.0
@mxschmitt
Copy link
Member Author

Weird, was yesterday able to reproduce it consistently, my suspicion is that it was a Node.js bug, which is probably fixed in recent Node.js - waiting for our customer to try out recent Node.js.

@Makeshift
Copy link

I believe I've been encountering something similar for the past few days, where certain interactions between the VSCode debugger, Yarn and AWS-CDK causes a hang.

I created a reproduction repo here, but thankfully found a workaround in the form of switching to the nightly version of the debugger extension. I haven't dug much more into it, but hopefully this helps someone.

@mxschmitt
Copy link
Member Author

I'll close it for now since we are not able to reproduce anymore. We did a few changes around debugging (cwd, which might have been related) @Makeshift, if you still experience issues, I recommend filing a separate bug, so we don't mix. Thanks!

@mxschmitt mxschmitt closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
@mxschmitt
Copy link
Member Author

Just for further reference, the issue in our case was: We were passing a number value as an arg. This ended up in:

ERR [Extension Host] TypeError: o.includes is not a function
    at Roe (c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\ms-vscode.js-debug\src\extension.js:117:346)
    at pp.launchProgram (c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\ms-vscode.js-debug\src\extension.js:115:9563)
    at n (c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\ms-vscode.js-debug\src\extension.js:115:4131)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at ap.launch (c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\ms-vscode.js-debug\src\extension.js:113:31785)
    at jI.captureLaunch (c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\ms-vscode.js-debug\src\extension.js:130:11414)
    at jI._launch (c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\ms-vscode.js-debug\src\extension.js:130:11161)
    at async Promise.all (index 3)
    at jI._boot (c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\ms-vscode.js-debug\src\extension.js:130:10285)
    at c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\ms-vscode.js-debug\src\extension.js:130:9214
    at mu._onMessage (c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\ms-vscode.js-debug\src\extension.js:47:4835)

here:

Maybe we should validate that string[] gets passed? Since the types only accept string[] inside js-debug extension, but when using the VSCode API, its pretty loose, its any I think.

@connor4312
Copy link
Member

connor4312 commented May 20, 2024

js-debug currently does no validation of the launch configuration passed to it. User-authored configurations will get warning diagnostics if they have something invalid in their launch.json based on the JSON schema, for API usages consumers just have to make sure they're giving valid data 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants