Skip to content
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

Can't attach to node in Docker #36192

Closed
chrisdias opened this issue Oct 13, 2017 · 8 comments
Closed

Can't attach to node in Docker #36192

chrisdias opened this issue Oct 13, 2017 · 8 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues

Comments

@chrisdias
Copy link
Member

git clone https://github.com/glimpse/stickerapp
cd stickerapp
git fetch
git checkout chrisdias/connect2017
npm install && code-insiders .

tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "taskName": "docker-compose",
            "command": "docker-compose",
            "args": [
                "-f",
                "docker-compose.debug.yml",
                "up"
            ],
            "identifier": "docker-compose"
        }
    ]
}

launch.json configuration:

        {
            "type": "node",
            "request": "attach",
            "name": "Docker",
            "address": "localhost",
            "port": 9229,
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/usr/src/app",
            "preLaunchTask": "docker-compose"
        }

press F5

result: docker-compose is run, but the debugger never attaches

add the detached flag to docker-compose in tasks.json:

        "args": [
            "-f",
            "docker-compose.debug.yml",
            "up",
            "-d"
        ],

F5

Result: "Cannot connect to runtime process...."

If you run docker-compose -f docker-compose.debug.yml -d from the terminal and then attach the debugger (without the preLauncTask) then I can attach the debugger.

@vscodebot vscodebot bot added the debug Debug viewlet, configurations, breakpoints, adapter issues label Oct 13, 2017
@isidorn
Copy link
Contributor

isidorn commented Oct 13, 2017

Following your exact steps I get the picture attached. Take note that I do not have any of the docker stuff installed on my machine.
Do you get the same if you set protocol: legacy or protocol: inspector to your launch.json

As for debugger not attaching that is probably coming from node2 thus assigning also to @roblourens
As for the first case that the debugger never attaches that would be an issue on the vscode side does it look something like this #35340

screen shot 2017-10-13 at 11 30 33

@isidorn isidorn added the info-needed Issue requires more information from poster label Oct 13, 2017
@roblourens
Copy link
Member

I don't see that file, is it docker-compose.dev.yml?

In that file all the --inspect args have different ports than 9229 specified, so do you need to set a different port in the launch config?

@chrisdias
Copy link
Member Author

I cleaned up the chrisdias/connect2017 branch. There is a tasks.json and a simplified launch.json in there now and you do need docker installed on the machine.

When I press F5 I get this:

image

Now, if you press F5 again, the debugger will attach because (I think) the container is running already. So, it's the first time.

A second problem I'm seeing here, but related. If I have a mistake in my tasks.json such that the command does not run, I cannot fix it and then run F5 again. I see a blue progress bar in the debug viewlet but when I try to terminate a running task, it tells me there isn't one.

@roblourens
Copy link
Member

I see the same thing. Can you try with a newer version of Node? It works if I add "protocol": "inspector" which implies that it's an issue with protocol detection. The same thing happened with an old Electron version. This is weird because I've never seen it with Node proper and can't repro with 6.11.4 locally.

What I see here, and saw with old Electron, is that after we try to detect the protocol, it won't let anything attach anymore. I can't even attach with chrome devtools after it gets into the broken state.

@chrisdias
Copy link
Member Author

ok, i see it work now with "protocol": "inspector". I've got node 8.5 on my mac so I can't seem to go much higher :). Also, I don't see the problem where I can't attach anymore.

@roblourens
Copy link
Member

I'll leave it open since it should work without specifying the protocol. I don't know why it's working differently between running node locally and in Docker.

@roblourens roblourens reopened this Oct 16, 2017
@roblourens roblourens changed the title cannot run docker-compose as preLaunchTask Can't attach to node in Docker Oct 16, 2017
@roblourens roblourens removed the info-needed Issue requires more information from poster label Oct 16, 2017
@isidorn isidorn removed their assignment Oct 27, 2017
@chrisdias
Copy link
Member Author

if i update the docker image to node 8, i cannot debug anymore.

All i did was change the Dockerfile to have this FROM statement:

FROM node:8-alpine

Press F5 and get this message:

image

@chrisdias
Copy link
Member Author

need to use this in the docker-compose file...

    command: node --inspect=0.0.0.0:9229 server/index.js

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues
Projects
None yet
Development

No branches or pull requests

3 participants