vscode-go
vscode-go copied to clipboard
Couldn't start dlv dap: Error: No available ports found
{ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "main", "type": "go", "request": "launch", "mode": "debug", "cwd": "./", "program": "main.go", } ] }
launch.json like this.
when I run dlv in vscode debug , the command while execute /usr/local/go/bin/dlv dap --listen=127.0.0.1:45863 --log-dest=3 from /projects/path
but some times , the Error happened . And I run debug repeatedly multiple times will solve the problem. How can I fundamentally solve such a problem?
Hi @Aatroy, Thanks for reporting the issue.
I was not able to re-produce the issue you encountered. My experience is normally smooth.
See goDebugFactory.ts the vscode go extension need to find an available port and the port will be passed to dlv --listen flag.
Looks like the error happened even before the dlv is running. VSCode-Go uses the "get-port" (npm install get-port) to Get an available TCP port. If no port is available, it will throw an error throw new Error('No available ports found'); See source.
The version we are using is pretty old though. But I do not find a lot diff between the v5.1.1 and the v7.1.0 (latest).
Could you check if there is port available in your localhost though? I think this is not related to which code base you are trying to debug.
Hi @Aatroy, Thanks for reporting the issue.
I was not able to re-produce the issue you encountered. My experience is normally smooth.
See
goDebugFactory.tsthe vscode go extension need to find an available port and the port will be passed to dlv--listenflag.Looks like the error happened even before the dlv is running. VSCode-Go uses the "get-port" (
npm install get-port) to Get an available TCP port. If no port is available, it will throw an errorthrow new Error('No available ports found');See source.The version we are using is pretty old though. But I do not find a lot diff between the v5.1.1 and the v7.1.0 (latest).
Could you check if there is port available in your localhost though? I think this is not related to which code base you are trying to debug.
I tested get-port function with this code in centos 6.3 and 7.5 `const getPort = require('get-port');
getPort().then((port) => { console.log(port); }); ` in 6.3 , I got "No available ports found" many times, but in 7.5 , all test is success. Maybe is OS problem;
goDebugFactory.ts
how can i edit this file , I tried use getPort({ host: '127.0.0.1' }) ,then centos 6.3 work successfully all times. @h9jiang
You can follow the contributing guide here
Once you download the repo, you can launch another vscode with the developing version of go extension. Then you can test the behavior of those functions. By default, the new vscode only have one extension (which is the developing version of go extension).
You can make local modification for this file goDebugFactory.ts with logs or just add a breakpoint and re-launch to see why this is happening in 6.3 but working in 7.5.
Thank you.