Skip to content

Couldn't start dlv dap: Error: No available ports found #3756

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

Open
Aatroy opened this issue Apr 21, 2025 · 4 comments
Open

Couldn't start dlv dap: Error: No available ports found #3756

Aatroy opened this issue Apr 21, 2025 · 4 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@Aatroy
Copy link

Aatroy commented Apr 21, 2025

Image

{ // 使用 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?

@gopherbot gopherbot added this to the Untriaged milestone Apr 21, 2025
@h9jiang
Copy link
Member

h9jiang commented Apr 23, 2025

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.

@h9jiang h9jiang added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 23, 2025
@Aatroy
Copy link
Author

Aatroy commented May 8, 2025

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.

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;

@Aatroy
Copy link
Author

Aatroy commented May 8, 2025

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

@h9jiang
Copy link
Member

h9jiang commented May 8, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants