-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Remote debugging not working again #22306
Comments
I am also facing this problem at the moment. I'm running pretty much the exact same configurations: running on a Mac, trying to connect the debugger to node inside docker, no error is shown and the debug control panel just never appears. Toggling Dev Tools doesn't provide any extra info either, there's no error in the console there. |
I've been using the VSCode debugger for a Node app on a Mac for a while. We just switched our dev environment to run things via docker-compose, so I just started having this same issue. A question for those of you having the same problem: are you able to debug in Chrome DevTools? I start my app with |
This is also my suspicion, though I thought I ruled it out with a Though one interesting thing is, although I don't get the same error. Nothing works in my debugger console. I will file an issue on Docker as well. |
Yep, definitely pasting the right URI. In fact I just repeated this scenario on a Ubuntu 16.04 machine and got the same result! Strange. I'll keep digging into it and update this thread or the docker one as appropriate. |
I am facing the same problem but I managed to attach the chrome devtool to the node running inside a container. Just run node with --inspect=0.0.0.0 rather than pure --inspect as it will only listen to a local connection. This way, I can get the chrome's devtool to work. For this reason, I doubt there is something wrong with Docker. This is supposed to be a bug in VS code itself. |
Thank you! I had a feeling there was some flag I hadn't tried yet. Glad to hear we can still debug somewhere until this VSCode issue is resolved. Thanks again. |
By the way, I can now get the VSCode debugger to attach when starting the node app with |
@mulleady1 Glad to hear you managed to get it to work so this can prove it might not be a VS Code bug. Would you mind sharing with me a couple of things as follows:
I am still struggling to get this to work. I can get Devtool to attach quite fine but not for VS code. |
Sure thing.
|
@woraphol-j Same here! As for trying to attach VScode, still no luck. I'm using node 7.7.1 as well and my launch.json is the same as @mulleady1 |
VSCode (as well as Chrome Debugger) should support source map? I'm just wondering if you can attach the Chrome Debugger to a remote container using |
Can you do a quick test? Let me know if that works. []'s |
@mulleady1 Do you mind share your Docker version as well? |
@navossoc Bingo!! |
@woraphol-j I have traced my issue to Seems there is a protocol change for node debugger and that transition is what is creating this whole problem. You can also set the I'm using node v6.10.1. and my {
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}\\lib\\index.js",
"protocol": "auto"
}, |
Hi, I observe the same issue when running my docker container (based on node:7.7.2-alpine) in docker-machine (VirtualBox) on Windows 7 and then trying to attach to it from vscode.
Here I run the application with the following
When I start the application I am able to see the following in the console:
When I open the url in the chrome (replacing After reading the above I did not clearly understand if somebody has the exact same behavior and if it has a workaround. Additional note. |
Seems to be related to the issue: #23257 |
I just added a "VS Code Recipe" for how to debug transpiled source in Docker with VS Code. Please see https://github.com/weinand/vscode-recipes/tree/master/Docker-TypeScript |
@weinand I don't see any new configurations that you are using that might make my case work. |
@tinganho does it help if you add a |
I tested with following, debug not work. I am running in Mac with docker 17.03.1-ce, node v7.10.0 , VS code 1.12.2.
BTW, I also tried for setting of |
@AndrewLaBabies does your program break correctly if you add a "debugger" statement? |
Just FYI to whomever, remote debugging has been working like a charm for me lately. The biggest difference in my setup from when I was having trouble is that I switched to the edge channel for Docker for Mac. My configuration is: Start node with launch.json:
Docker Node Mac |
@weinand , sorry for the late response. But the breakpoints set in vs code directly, which still don't work. |
@AndrewLaBabies if your debugger statement does not result in a break in the TypeScript file but breaks in the generated JavaScript, I suspect that your source maps are missing or incorrect. Make sure that the generated Javascript has a reference at the end that points to the source map and that the sourcemap has an entry in the "sources" array that points to the TypeScript file. See my recipe for how that could look like. |
@weinand sorry for late response here as well.
As I downloaded a newer version of VSCode, it seems like I'm able to break(only using the inspector protocol), but only in JS file. I checked the One another thing is that the node process stalls (and I have to manually kill the process), when I try to detach the debugger(though, I'm not sure if it is VSCode fault here). It would be good if other people can confirm this as well. It seems like my problem only occurs specific to my project. As I cannot create minimum verifiable bug case. (Though if you have async/await code it jumps to JS code, but it jumps back to TS code, in my minimum bug case). I can do some more digging, when I got more time. |
@tinganho you said: "if you have async/await code it jumps to JS code, but it jumps back to TS code". This is normal since the generated sourcemap does not cover all the generated JavaScript. So there are "holes" in the JavaScript that doesn't map to TypeScript. You can avoid stepping through the JavaScript by setting the "smartStep" attribute to true. |
@weinand , I double confirmed the sourceMaps were generated correctly, and sourceRoot pointing to the correct ts folder in docker container |
@tinganho VS Code cannot access TypeScript source in the container and the node.js runtime doesn't care about the TypeScript. The logic for finding the source in a remote Docker scenario is as follows:
Please note: the above logic applies to the case where the source lives in separate files. If the source is inlined in the source map and the source map itself is inlined in the JavaScript, VS Code tries to use the inlined source. |
@weinand I think I got the debugging working now. I didn't made any changes. Though I added and removed some debugging configurations. And at last I got it to work. I'm suspicious whether there could be any caching bug? Because my configurations looks exactly the same as before. I think because my addition and deletion of configurations made my debugging configurations to take effect. Honestly, my debugging experience haven't been consistent, sometimes I cannot set breakpoints, sometimes I can. Sometimes other problems occur, sometimes not. It was very hard to pin point the exact problem. |
In my recent experience is that the breakpoint only breaks correctly if I explicitly add a "debugger;" statement in my source code. |
I ran in to these issues, used the 0.0.0.0 fix to get attach working again. Also needed to make sure the localRoot was correct in order for breakpoints to hit (in the launch.json). You'd also probably find when it only works with debugger statements it's not breaking in the actual code file. |
* upstream/master: (315 commits) Update README.md Update readme with new attach config Upgrading docker image to node 8.2.1 & updating readme to match fixes Updated to use node inspector & fix issue with debug not attaching https://nodejs.org/en/docs/inspector/ Note that 0.0.0.0: came from microsoft/vscode#22306 Adding ignore file and updating npm >5 updating instructions on swarm mode lab to encourage using Play with Docker Update labs for single-node swarms Remove Broken Link Update README.md Make link description a little clearer Update ch11-bigdata.adoc fix formatting issue (docker#302) fix issues preventing Sails app from starting Fix link location fix link typo (docker#299) Update the explanation to match with tutorial steps (docker#298) Fixed typos & grammar in Netbeans/Eclipse/IntelliJ Spanish examples (docker#296) fix link to rotate_certs Summarizing reviewers' advice First push to convert all Docker Hub references to Docker Cloud and Docker Store ...
If you're using jest, you may need to use the --no-cache option for jest. This fixed debugging for me in some cases. |
Since this issue is quite old, and the discussions are difficult to follow, and VS Code is now at version 1.20.1, I will close this issue. If you still see issues in 1.20.1 please open new issues. |
I'm not sure in which version of VSCode remote debugging broke for me. But I know it broke for perhaps within 2 months.
These are the settings I've been using for a long time before it broke(and they have been working for many months):
I'm using Docker Compose for development:
I'm using Docker for Mac and I have a debugger breaked on entrance. I run a
tcpdump
to ensure the VSCode can reach the node runtime.I can confirm it can reach because some packets are showing every time I click on the attach button.
And I'm using Mocha to issue the debug break statement
There is no outputted error on VSCode (Debug Console) and when I try to attach to it, it loads a bit and then nothing happens the loading indicator disappears. There are no Debug buttons appearing as usual.
I tried to attach locally by running the same command and it works. Just remote debugging (in a Docker container) doesn't work for me.
The text was updated successfully, but these errors were encountered: