Debugging session does not start under Docker with Node 8 on Alpine

Of course I think I have everything set up right, but this is all new to me.

I have a Docker container running Node.js v8.11.4 under Alpine 3.6. I set up WebStorm 2018.2.2 with Docker according to the help files and with Automatic Configuration, and I followed the instructions under "Debugging a Node.js application in a Docker container". I set breakpoints as early as I could in the source. 

When I hit the debug icon, WebStorm builds a Docker image, runs it, and I see the "Debugger listening on" message on the console. However, the WebStorm debugger never seems to connect. I never hit a breakpoint, and if I press the pause button on the debugger nothing happens. 

I can connect to the debugger port from Terminal, and /json/list gives me the same UUID I see in the WebStorm console. It uses the containers internal network address in the webSocketDebuggerUrl field instead of the Docker server address, but that shouldn't matter as the "Debugger listening on" message shows the correct IP address to connect to. 

I don't see anything fishy in the idea.log logfile and the docker.log file is empty. 

When I run commands inside the Docker container, I see that Node is running and the debugger port is open, but there are no listeners other than the debugger port, which is consistent with the app never getting started (and opening its ports). 

 UPDATE

OK, I see node is stopping on startup because WebStorm is passing the deprecated "--debug-brk" flag. I can't seem to get that to go away. If I add "--inspect" to the Node parameters, "--debug-brk" remains even if I add "--inspect-brk". If I add "--inspect-brk" without "--inspect", WebStorm fails to assign an address, it defaults to 127.0.0.1, and I cannot connect to it. 

I can connect to the debugger with Chrome DevTools and continue the process, but still WebStorm never connects. 

How do I move forward to get remote debugging working?

8 comments

 Please attach screenshots of your run configuration and docker settings

0

Unfortunately, I cannot reproduce the problem in WebStorm 2018.2.2 using the project generated with "File | New | Project... | Node.js Express App". Is it reproduced for you? If yes, any particular steps to reproduce?

0

Sergey, I reproduced it using an HTML5 Boilerplate project, not an Express project. I put "hello world" code in src/js/main.js and ran node with that file using Docker node:8 as the remote Node.js interpreter (with Auto configure). 

(I meant to start with an empty project, but I guess the mouse slipped and I got the HTML5 project. Since I'm new to WebStorm I didn't realize that this was unintentional; I thought this was default boilerplate for an empty project.)

 

0

Sorry for the delay. What's your WebStorm version? See "Help | About".

Unfortunately, I couldn't reproduce the issue so far. Please start the script with node using Docker node:8 as you did before. Then, find running container in Terminal with command `docker container ls` and attach here output of `docker container inspect <container-id>`. Thanks!

0

Sergey, I'm using:

WebStorm 2018.2.2
Build #WS-182.4129.32, built on August 20, 2018
JRE: 1.8.0_152-release-1248-b8 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.11.6

Here's the result of docker container inspect:

[
{
"Id": "f1c5fcd0dab0eddfe0975d9f1d7df6d5b517bb55f28138cd5c64b97ecadffb02",
"Created": "2018-09-12T16:43:24.733857025Z",
"Path": "/bin/sh",
"Args": [
"/tmp/project_modules/start.sh",
"--inspect=0.0.0.0:63328",
"--debug-brk",
"/opt/project/src/js/main.js"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 31544,
"ExitCode": 0,
"Error": "",
"StartedAt": "2018-09-12T16:43:27.220034069Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:59c7d0e80ea9c2599a5dbc2cd68548c3e6776454f5706eab81f7b1fe32ddf9e8",
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/f1c5fcd0dab0eddfe0975d9f1d7df6d5b517bb55f28138cd5c64b97ecadffb02/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/f1c5fcd0dab0eddfe0975d9f1d7df6d5b517bb55f28138cd5c64b97ecadffb02/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/f1c5fcd0dab0eddfe0975d9f1d7df6d5b517bb55f28138cd5c64b97ecadffb02/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/f1c5fcd0dab0eddfe0975d9f1d7df6d5b517bb55f28138cd5c64b97ecadffb02/f1c5fcd0dab0eddfe0975d9f1d7df6d5b517bb55f28138cd5c64b97ecadffb02-json.log",
"Name": "/brave_neumann",
"RestartCount": 0,
"Driver": "aufs",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/Users/user/Documents/WebStorm/hello:/opt/project:rw",
"/Users/user/Library/Caches/WebStorm2018.2/tmp/node_modules:/opt/project/node_modules:rw"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "bridge",
"PortBindings": {
"3000/tcp": [
{
"HostIp": "192.168.99.100",
"HostPort": "3000"
}
],
"63328/tcp": [
{
"HostIp": "",
"HostPort": "63328"
}
],
"63329/tcp": [
{
"HostIp": "",
"HostPort": "63329"
}
],
"63330/tcp": [
{
"HostIp": "",
"HostPort": "63330"
}
],
"63331/tcp": [
{
"HostIp": "",
"HostPort": "63331"
}
],
"63332/tcp": [
{
"HostIp": "",
"HostPort": "63332"
}
],
"63333/tcp": [
{
"HostIp": "",
"HostPort": "63333"
}
],
"63334/tcp": [
{
"HostIp": "",
"HostPort": "63334"
}
],
"63335/tcp": [
{
"HostIp": "",
"HostPort": "63335"
}
],
"63336/tcp": [
{
"HostIp": "",
"HostPort": "63336"
}
],
"63337/tcp": [
{
"HostIp": "",
"HostPort": "63337"
}
],
"63338/tcp": [
{
"HostIp": "",
"HostPort": "63338"
}
],
"63339/tcp": [
{
"HostIp": "",
"HostPort": "63339"
}
],
"63340/tcp": [
{
"HostIp": "",
"HostPort": "63340"
}
],
"63341/tcp": [
{
"HostIp": "",
"HostPort": "63341"
}
],
"63342/tcp": [
{
"HostIp": "",
"HostPort": "63342"
}
],
"63343/tcp": [
{
"HostIp": "",
"HostPort": "63343"
}
],
"63344/tcp": [
{
"HostIp": "",
"HostPort": "63344"
}
]
},
"RestartPolicy": {
"Name": "",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": null,
"DeviceCgroupRules": null,
"DiskQuota": 0,
"KernelMemory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": 0,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/asound",
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": null,
"Name": "aufs"
},
"Mounts": [
{
"Type": "bind",
"Source": "/Users/user/Documents/WebStorm/hello",
"Destination": "/opt/project",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/Users/user/Library/Caches/WebStorm2018.2/tmp/node_modules",
"Destination": "/opt/project/node_modules",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "f1c5fcd0dab0",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3000/tcp": {},
"63328/tcp": {},
"63329/tcp": {},
"63330/tcp": {},
"63331/tcp": {},
"63332/tcp": {},
"63333/tcp": {},
"63334/tcp": {},
"63335/tcp": {},
"63336/tcp": {},
"63337/tcp": {},
"63338/tcp": {},
"63339/tcp": {},
"63340/tcp": {},
"63341/tcp": {},
"63342/tcp": {},
"63343/tcp": {},
"63344/tcp": {}
},
"Tty": false,
"OpenStdin": true,
"StdinOnce": false,
"Env": [
"DEBUG_COLORS=true",
"MOCHA_COLORS=1",
"ELECTRON_NO_ATTACH_CONSOLE=true",
"npm_config_color=always",
"FORCE_COLOR=true",
"COLORTERM=true",
"JETBRAINS_REMOTE_RUN=1",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NODE_VERSION=8.11.4",
"YARN_VERSION=1.6.0"
],
"Cmd": [
"/bin/sh",
"/tmp/project_modules/start.sh",
"--inspect=0.0.0.0:63328",
"--debug-brk",
"/opt/project/src/js/main.js"
],
"Image": "sha256:59c7d0e80ea9c2599a5dbc2cd68548c3e6776454f5706eab81f7b1fe32ddf9e8",
"Volumes": null,
"WorkingDir": "/opt/project",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "a702b54bf42157c06c3f3b973035f46a83273854a1fef5d9763a4d61c15cc887",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"3000/tcp": [
{
"HostIp": "192.168.99.100",
"HostPort": "3000"
}
],
"63328/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63328"
}
],
"63329/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63329"
}
],
"63330/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63330"
}
],
"63331/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63331"
}
],
"63332/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63332"
}
],
"63333/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63333"
}
],
"63334/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63334"
}
],
"63335/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63335"
}
],
"63336/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63336"
}
],
"63337/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63337"
}
],
"63338/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63338"
}
],
"63339/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63339"
}
],
"63340/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63340"
}
],
"63341/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63341"
}
],
"63342/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63342"
}
],
"63343/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63343"
}
],
"63344/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "63344"
}
]
},
"SandboxKey": "/var/run/docker/netns/a702b54bf421",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "6c236afb95eb49845d96c43ced25e0d7cc4b99066317768e60d7b0015102f726",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:03",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "9902452d444d388c9e6699179331eecc35e8802c7ed3b276025e7dd5c35658e7",
"EndpointID": "6c236afb95eb49845d96c43ced25e0d7cc4b99066317768e60d7b0015102f726",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03",
"DriverOpts": null
}
}
}
}
]

0

Zorro, sorry for the delay. Thanks for the information! Could you please change `src/js/main.js` content to

console.log("Node version: " + process.version);

Run (not debug) the script with Docker and attach here full console output.

Then, please debug the script with Docker and attach here full console output too.

Unfortunately, I still cannot reproduce the problems when debugging Node.js app with Docker. Please see my screencast (https://www.dropbox.com/s/3v8jwb93zdezaqt/debugging-with-docker.ogv?dl=0) showing how it works for me. Is there anything different in your setup?

It'd be great if you could capture a similar screencast showing the issue. That would speedup the investigation.

0

I'm guessing we have a few differences in our configurations.

Probably most significant is that I'm running Docker Toolbox 18.06.0-ce on OS X 10.11.6 (both the latest versions my hardware supports) and I'm guessing you are running Docker for Mac. Also, I did not start a docker container outside of WebStorm, instead WebStorm starts a container with each run (and stops and deletes it after it is done). When I click "Run" or "Debug" I get a "Building Project Image" progress dialog that takes a while, and a significant delay between the first line of the console output and the console log of the Node version. I'd love to know how you get your process to start so quickly. 

Probably less significant, I have my working directory set to "~/Documents/WebStorm/hello" and JavaScript file set to "src/js/main.js".

--- Begin console output of Run ---

docker://node:8/node /opt/project/src/js/main.js
Node version: v8.11.4

Process finished with exit code 0

--- End console output of Run ---

--- Begin console output of Debug ---

docker://node:8/node --inspect=0.0.0.0:56076 --debug-brk /opt/project/src/js/main.js
Debugger listening on ws://0.0.0.0:56076/4f272c36-92e4-4564-a2da-f49e122b1a9b
For help see https://nodejs.org/en/docs/inspector


--- End console output of Debug ---

That's all I get from the Debug run until I click the stop button. If I attach the Chrome Node Debugger to the specified port, I see that the process has stopped as expected from "--debug-brk" (even thought that flag is deprecated on Node 8). 

0

Thanks for the information! Actually, I'm on Linux with Docker version 18.06.1-ce, build e68fc7a. Probably docker on Linux behaves differently than on Mac. I don't start a docker container outside of WebStorm either. Missing "Building Project Image" progress dialog is likely caused by missing package.json file for some reason. Now, there is the progress dialog with package.json file in the project root: https://www.dropbox.com/s/zn9okh1gz6hy1qu/debugging-node-docker.mp4?dl=0

Please collect the additional log file:
* Help | Find Action...
* Type "Registry..." and open the Registry dialog.
* Find `js.debugger.wip.log` key and specify a new file path as its value (in an existent directory).
* Close dialog and reproduce the issue with not started debugging session.

Could you please create a new issue in the https://youtrack.jetbrains.com/issues/WEB and attach the log there? I think it'd be better to continue the discussion in issue.

Is the issue reproduced in WebStorm 2018.2.3 or/and WebStorm 2018.3 EAP (https://www.jetbrains.com/webstorm/eap/)?

0

Please sign in to leave a comment.