microsoft / vscode-js-debug

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

`cwd` isn't set by default when using clients other than vscode #2040

Closed igorlfs closed 4 months ago

igorlfs commented 4 months ago

Describe the bug Hello! It looks like the logic to set the CWD is coupled with vscode. When using other clients (eg, nvim-dap), it is necessary to "manually" set the "cwd" for the debugger to launch.

To Reproduce For neovim, I can provide a minimal init.lua, if necessary. Given a working DAP setup, it's just a matter of:

  1. Set a breakpoint;
  2. Start a debugging session;
  3. The debugger doesn't launch (or attach) if the parameter is missing from the configuration.

Log File

Firstly, nvim-dap logs

[debug-adapter stderr] TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined
    at Object.relative (node:path:1194:5)
    at YH (/home/dev/.local/share/nvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js:113:2456)
    at $u.launchProgram (/home/dev/.local/share/nvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js:116:405)
    at n (/home/dev/.local/share/nvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js:113:4094)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Su.launch (/home/dev/.local/share/nvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js:110:30910)
    at async sg.captureLaunch (/home/dev/.local/share/nvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js:116:9417)
    at async sg._launch (/home/dev/.local/share/nvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js:116:9164)
    at async Promise.all (index 3)
    at async sg._boot (/home/dev/.local/share/nvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js:116:8288) {
  code: 'ERR_INVALID_ARG_TYPE'

And the log file from the trace, here.

VS Code Version: N/A

Additional context This situation is a bit of a bummer, since it might lead users to believe this adapter only works with vscode.

igorlfs commented 4 months ago

Thanks for the quick fix!