-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
dap.terminate doesn't kill all processes #446
Comments
Wasn't this fixed in #343 ? Do you know which process isn't terminated? the debug-adapter or the debugee? Terminate shouldn't even be required, according to the specification if you're using a launch request the debugee should terminate by itself if it runs to completion. Sounds a bit like a bug in the debug adapter. Unfortunately vscode-node-debug2 is no longer maintained :/ |
I'm also not sure what else nvim-dap could be doing. The |
Hi @mfussenegger , Thanks a lot for your response,
It seemed to work at the time of #343 , but now there are still some left-over processes. I recorded a video to demonstrate it. The first few times I debug the test and wait until it finishes - all processes are destroyed in the end. The exact code to debug the test right after local function terminate(cb)
local dap = require('dap')
print "calling terminate..."
dap.terminate({}, {}, function()
print "calling terminate finished..."
cb()
end)
end
terminate(function()
return run(o) -- run calls `dap.run` in the end
end) I did another test: This time I stop at a breakpoint and call Best regards, |
For jest tests, I was able to get For jest it looks like it ignores the breakpoints as well but then eventually they do end up working. Potentially sending them to the right process (and not to others) might make it work for all things. |
Thanks a lot for the information @entropitor and @mfussenegger ! Regarding Jest: I noticed that it also works for dap.run({
-- ...,
disableOptimisticBPs = true
}) together with a {
"sourceMaps": true,
"retainLines": true
} |
@David-Kunz I think for the vscode-js-debug one, it might also have to do with the fact that they are being send to the "root session" which then rejects them and the actual "child" session doesn't reject them and so it works but I'm not sure, I never fully investigated. |
I see, seems like a lot of trouble with Regarding the processes: As a workaround, I will close the current process manually ( The callback function doesn't seem to work in all cases and occasionally leaves some processes running: dap.terminate({}, {}, function()
-- start next debug session here
end) |
Could be that it doesn't set the dap.terminate(nil, nil, function()
-- start next debug session here
end) |
Will try immediately! |
It seems to work (I restarted a debugging session ~10 times and don't have any more Node.js processes). There is only a problem when I spam debugging processes (starting the next one without waiting until the one before is properly started), then I still have Node.js processes which are not terminated. So I guess the |
Do you think you could create a minimal project and a minimal reproduction so I could look into it? |
Hi @mfussenegger , Thanks for looking into it! Minimal Example: File: test.js
Lua configuration for node2: dap.adapters.node2 = {
type = 'executable',
command = 'node',
args = {os.getenv('HOME') .. '/apps/node/out/src/nodeDebug.js'}, -- or wherever your file is
} Lua function to execute test: _G.test_dap = function()
local dap = require'dap'
dap.terminate(nil, nil, function()
dap.run({
args = { "--no-cache" },
console = "integratedTerminal",
cwd = "<your_CWD>", -- <<<<<<<<<<<< please adjust!
disableOptimisticBPs = true,
port = 9229,
protocol = "inspector",
request = "launch",
runtimeArgs = { "--inspect-brk", "test.js" },
skipFiles = { "<node_internals>/**/*.js" },
sourceMaps = "inline",
type = "node2"
})
end)
end Test:
Note:
Best regards, |
I think the problem is that many parts of You could try adding something like a
After the terminate, but not sure if that will help. I also think that the debug adapter has a problem - because the logs say that the process gets closed and a debug-adapter launched in |
If I perform _G.test_dap = function()
local dap = require'dap'
dap.terminate(nil, nil, function()
vim.wait(2000, function()
dap.run({
args = { "--no-cache" },
console = "integratedTerminal",
cwd = "your-cwd", -- <<<<<<<<<<<< please adjust!
disableOptimisticBPs = true,
port = 9229,
protocol = "inspector",
request = "launch",
runtimeArgs = { "--inspect-brk", "test.js" },
skipFiles = { "<node_internals>/**/*.js" },
sourceMaps = "inline",
type = "node2"
})
end)
end)
end Then I get the error message
|
Not surprising. Take a look at |
Oh I see, sorry for not reading the documentation. It waits until the callback is done - I thought it would wait and then call the callback... let me check again. |
Okay, with the following _G.test_dap = function()
local dap = require'dap'
dap.terminate(nil, nil, function()
vim.wait(2000, function()
local session = dap.session()
return session and session.initialized
end)
dap.run({
args = { "--no-cache" },
console = "integratedTerminal",
cwd = "...", -- <<<<<<<<<<<< please adjust!
disableOptimisticBPs = true,
port = 9229,
protocol = "inspector",
request = "launch",
runtimeArgs = { "--inspect-brk", "test.js" },
skipFiles = { "<node_internals>/**/*.js" },
sourceMaps = "inline",
type = "node2"
})
end)
end it can restart, but previous sessions remain. The effect is that when stopped at a breakpoint, I can't continue. I get the error message, that there's no configuration. |
Hello, I'm working on integrating the user's npm scripts into the DAP config automatically, it works really well but the process does not get killed when the debug session is over. I found out that if you use the integrated console when running the debugger with the option I read above that @mfussenegger talked about giving the console pid as part of the execution context, was this implemented? I'd love to be able to use this and append a function to the terminated/exited events in order to cleanly stop the running process. It would also be a better option in order to make my plugin adapter-agnostic. Here's the config I'm running to launch npm scripts: {
name = "Run script",
type = "pwa-node",
request = "launch",
cwd = "${workspaceFolder}",
rootPath = "${workspaceFolder}",
sourceMaps = true,
skilpFiles = { "<node_internals>/**" },
protocol = "inspector",
console = "integratedTerminal",
runtimeExecutable = "npm",
runtimeArgs = {
"run-script",
"some_npm_script"
}
}
Cheers |
Problem Statement
Hi,
In my plugin Jester I use the following code to terminate the current session
However, this does seem to terminate all processes or it won't terminate the next session which is about to be created afterwards.
What I usually do:
dap.terminate({}, {}, cb)
wherecb
debugs it againIdeas or possible solutions
Is there a way to force
nvim-dap
to kill all running processes to have a clean state? Otherwise, over time, the amount of running processes makes my machine spin too much.Thanks a lot!
The text was updated successfully, but these errors were encountered: