-
Notifications
You must be signed in to change notification settings - Fork 520
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
Attach - preLaunchTask not working as expected #3439
Comments
I'll take a look and see if there's a way to do this. Unfortunately we have no control over when I think what may be happening when |
So I've had a read through the code myself to try and get a bit more of an understanding of how all this works. By the looks of it (I haven't done any debugging) the errors are probably getting thrown during the check to see if the debugger needs to be installed into the container when resolving the configuration. I wonder whether a solution to this might be to override the preLaunchTask that gets resolved with another task that first runs the original preLaunchTask (or a task provided by a new docker specific field?) and only once that's completed try and install the debugger, rather than trying to do it during the resolve? |
Hi there, Another workaround is the described way in https://code.visualstudio.com/docs/containers/docker-compose#_python. Left click on I hope, you can fix this issue. Below, you find my Cheers! tasks.json:
launch.json:
Dockerfile:
docker-compose.dev.yml
|
I think you're right @adibradfield; the debugger check is happening during the debug config resolve phase (which is before the containers are started). If you set the following {
"name": "Docker .NET Core Attach (Preview)",
"type": "docker",
"request": "attach",
"platform": "netCore",
"sourceFileMap": {
"/src": "${workspaceFolder}/Integrations.Equifinance"
},
"containerName": "fmg-equifinance-debug",
"preLaunchTask": "compose-up-dev",
"postDebugTask": "compose-stop-dev",
"netCore": {
"debuggerPath": "/remote_debugger/vsdbg" // Add this `netCore.debuggerPath` option, with this value
}
}, Setting this value bypasses the debugger check. Sample compose document with the debugger mapping: # Please refer https://aka.ms/HTTPSinContainer on how to setup an https developer certificate for your ASP .NET Core service.
version: '3.4'
services:
net6app:
image: net6app
build:
context: .
dockerfile: ./Dockerfile
ports:
- 5287:5287
environment:
- ASPNETCORE_ENVIRONMENT=Development
volumes:
- ~/.vsdbg:/remote_debugger:rw # This is what maps in the debugger If the debugger is not yet installed on your local machine, running the "Docker .NET Core Attach (Preview)" launch configuration once without the |
@Lukas-J for your Python app--I've seen similar issues, where the first run starts the app but no debugger is launched, and then the second attempt does start debugging. It has something to do with the somewhat complicated way that debugging is initiated in Python apps. I'm guessing that the container is started, with debugpy being installed and then starting, but before that happens the Python debugger tries to attach. @int19h is there a way to set up retries / a timeout on the Python attach config? @Lukas-J tasks can depend on other tasks, so one possible option would be to have the |
There is a timeout in debugpy, but it's not configurable, and the exact value depends on which stage it gets stuck on. For "attach" logic in vscode-python, it relies on VSCode's own builtin support for DAP over TCP, so whatever timeout / retry functionality is available should be applicable - but I don't recall there being any last time I checked. @paulacamargo25 might have more up-to-date knowledge on this. |
If the stuck stage is in waiting for We install and launch Obviously depending on connection it could take a long time to download and install |
For "attach", the VSCode side is not aware of debugpy lifecycle when connecting - it (or rather VSCode itself, since the extension just returns the host/port to connect to) simply connects to the specified address. For that one, the timeout is also determined by VSCode. If I remember correctly, it was somewhere on the order of 1 minute. |
tasks.json:
launch.json
|
RE: the Python issue; I did some poking around in VSCode's debug adapter client code. It doesn't appear to accept any options. I'm guessing that since RE: the .NET issue; I think the ultimate solution is pretty much #2289. We can't verify/copy the debugger before the container is running, but the The simplest workaround is to manually run the compose up task/script/etc. before doing the Docker .NET attach, but of course this is an inconvenience. The only possible workaround for that is therefore to use the |
Hi again, |
I don't want the docs to get too far into the weeds...what do you think @ucheNkadiCode? Should we add docs or just let users discover this issue? |
@bwateratmsft this is something that has been mentioned enough that I wouldn't mind adding it to tips and tricks. Does this only exist in the world of python? Or .NET and other languages have this issue with prelaunch tasks? |
This is basically a duplicate of #3304 that got closed because the original reporter didn't provide extra information.
I am currently having the same issue where I am not able to setup my launch configurations in a way that I can do a
docker-compose up
before debugging, and adocker-compose down
once I've finished debuggingThe issue seems to be that the debugger tries attaching to the container before running the prelaunch task
This is what my launch configuration looks like:
Then I have my tasks:
I have tried the suggestion from the other issue to use the actual docker compose tasks, but I get the same result.
I get the following output:
If I remove the
containerName
property from the launch configuration I instead get this error:For now, to get around the issue I am running the
compose-up-dev
task from the command palette and then launching the debug session, and that works. This indicates to me that the likely cause is that the "preLaunchTask" is getting called at the wrong timeThe text was updated successfully, but these errors were encountered: