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

Node process doesn't get killed when terminating a debug session #45

Open
anatskiy opened this issue Apr 30, 2023 · 1 comment
Open

Comments

@anatskiy
Copy link

When I try to run a debug session of a basic node server, I can debug it just fine. But when I terminate the session (require('dap').terminate()) or disconnect from it (require('dap').disconnect({ terminateDebuggee = true })) and then rerun a new session, I get an error about the node server port being already in use, meaning, that the previous node process wasn't properly closed. I'm clueless about what to do ☹️

I've got the following config:

local DEBUGGER_PATH = vim.fn.stdpath('data') .. '/lazy/vscode-js-debug'

require('dap-vscode-js').setup({
  debugger_path = DEBUGGER_PATH,
  adapters = {
    'pwa-node',
    'pwa-chrome',
    'node-terminal',
  },
})

local dap = require('dap')

for _, language in ipairs({ 'typescript', 'javascript' }) do
  dap.configurations[language] = {
    {
      type = 'pwa-node',
      request = 'launch',
      name = 'Launch',
      program = '${file}',
      cwd = '${workspaceFolder}',
    },
    ...
  }
end

The installed version of vscode-js-debug is 1.78.0

@zyriab
Copy link

zyriab commented Sep 17, 2023

I'm working on it at the moment as I am implementing an extension to run the user's npm scripts directly from the DAP's options selector.
For the moment, the only way to do it from within Neovim that I found is to go into DAP-UI's integrated terminal (console), enter insert mode and press <C-c>.

I'm looking into a way to catch the terminal ID and kill it but in the meantime, that's the only solution I've found that's not too cumbersome.
Here's my config, for reference.
It's the same as the readme, the interesting part is:

 {
    name = "Run npm script",
    type = "pwa-node",
    request = "launch",
    cwd = "${workspaceFolder}",
    rootPath = "${workspaceFolder}",
    sourceMaps = true,
    skilpFiles = { "<node_internals>/**" },
    protocol = "inspector",
    console = "integratedTerminal",
    runtimeExecutable = "npm",
    runtimeArgs = {
        "run-script",
        "YOUR_NPM_SCRIPT" -- e.g.: "start"
    }
}

The interesting line is console = "integratedTerminal"
It works for "launch" and probably "attach" as well

I'll repost when (if?) I find a way to do that automatically.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants