mxsdev / nvim-dap-vscode-js

nvim-dap adapter for vscode-js-debug
266 stars 24 forks source link

Support `startDebugging` #38

Open mxsdev opened 1 year ago

mxsdev commented 1 year ago

Closes #15

A lot of the old configuration is now deprecated/legacy. Check out the docs/README for new configuration options.

A new compile command is also needed for vscode-js-debug:

npm install --legacy-peer-deps && npx gulp dapDebugServer

@JbIPS @igorlfs if you two would be willing to test this out locally and let me know if you have any issues, that would be super helpful πŸŽ‰

JbIPS commented 1 year ago

Great work @mxsdev ! I just tried it after a clean install, following the new Readme and got this:

Debugger attached.

  βœ” Set progress (166ms)
  ─

  1 test passed
Waiting for the debugger to disconnect...

[Process exited 0]

Seems great but the breakpoint didn't stop anything. Actually, it transformed into a red ΓΈ, maybe to indicate it couldn't connect ?

Here's my DAP setting:

{
    type = "pwa-node",
    request = "launch",
    name = "Debug AVA Test file",
    program = "node_modules/ava/entrypoints/cli.mjs",
    args = {
      '--serial',
      '${file}'
    },
    sourceMaps = true,
    skipFiles = {'<node_internals>/**/*.js'},
    outFiles = {
      "${workspaceFolder}/dist/**/*.js",
      "!**/node_modules/**"
    },
    outputCapture = "std",
    console = "integratedTerminal",
  }

I copied a working launch.json from VSCode (following AVA config) for this but I could have missed something.

For the record, my source file is in TS and build into dist

entropitor commented 1 year ago

I seem to be getting notify.error DAP Couldn't connect to localhost:${port}: ECONNREFUSED whenever I use it in combination with neotest-jest. ~It seems it's nor replacing "${port}" or something~

entropitor commented 1 year ago

It seems on MacOS, there are problems with localhost <> ipv4, ipv6. dapDebugServer by default uses localhost which for node means 127.0.0.1 (i.e. ipv4 localhost) while this / dap uses ::1 as localhost (i.e. ipv6 localhost) and thus we get a ECONNREFUSED.

The solution is to either pass explicitly 127.0.0.1 to both or ::1 to both instead of using localhost.