mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.67k stars 207 forks source link

node /path/js-debug-adapter.js doesn't die on neovim exit #1352

Open timsofteng opened 1 month ago

timsofteng commented 1 month ago

Debug adapter definition and debug configuration

local dap = require("dap")
require("dapui").setup()
dap.adapters["pwa-node"] = {
    type = "server",
    host = "localhost",
    port = "${port}",
    executable = {
        command = "node",
        args = {
            os.getenv("HOME") .. "/.local/share/nvim/mason/packages/js-debug-adapter/js-debug/src/dapDebugServer.js",
            "${port}",
        },
    },
}

require("dap").configurations.javascript = {
    {
        type = "pwa-node",
        request = "launch",
        name = "Launch file",
        program = "${file}",
        cwd = "${workspaceFolder}",
    },
}

dap.adapters.chrome = {
    type = "executable",
    command = "node",
    -- command = "chrome-debug-adapter",
    args = { os.getenv("HOME") .. "/.local/share/nvim/mason/packages/chrome-debug-adapter/out/src/chromeDebug.js" }, -- TODO adjust
}

dap.configurations.typescriptreact = {
    {
        type = "chrome",
        request = "attach",
        program = "${file}",
        cwd = vim.fn.getcwd(),
        sourceMaps = true,
        protocol = "inspector",
        port = 9222,
        webRoot = "${workspaceFolder}",
    },
}

dap.configurations.javascriptreact = {
    {
        type = "chrome",
        request = "attach",
        program = "${file}",
        cwd = vim.fn.getcwd(),
        sourceMaps = true,
        protocol = "inspector",
        port = 9222,
        webRoot = "${workspaceFolder}",
    },
}

Debug adapter version

js-debug-adapter 1.94.0

Steps to Reproduce

1.Create file test.js with this simple code

let count = 0;

function logMessage() {
  if (count < 10) {
    count++;
    console.log("count", count);
    setTimeout(logMessage, 1000); 
  }
}

logMessage();
  1. Set breakpoint into line setTimeout(logMessage, 1000); .
  2. Run :lua require'dap'.continue().
  3. Run :lua require'dap'.restart().
  4. :qa.

Expected Result

All related not processes should be killed.

Actual Result

node /path/js-debug-adapter.js process exists.

mfussenegger commented 1 month ago

This sounds like a js-debug-adapter issue. nvim-dap sends a terminate for all active sessions started with launch, when vim exits and other debug adapters also quit cleanly.