Can you use node-debug on a non-webserver application?

151 views Asked by At

I'd like to debug an application which is basically a straightforward text-processing pipeline. After messing around with node-debug for a while (Vagrant port forwarding issues), all I get in the browser is output like:

Type: connect
V8-Version: 3.14.5.9
Protocol-Version: 1
Embedding-Host: node v0.10.25
Content-Length: 0

Content-Length: 96

{"seq":0,"request_seq":1,"type":"response","command":"disconnect","success":true,"running":true}Content-Length: 553

There's no debug GUI.

Is it actually possible to debug a nodeJS application this way if it doesn't run a web server?

I'm starting node-debug like this:

coffee --nodejs --debug-brk toLineString.coffee

EDIT

Following @Brad's suggestion, I get further but it still doesn't quite work:

$ coffee --nodejs --debug-brk toLineString.coffee
debugger listening on port 5858

In another tab: $ node-debug info - socket.io started

Now, in a browser window, I go to http://localhost:8080/debug?port=5858

![enter image description here][1]

There's only boilerplate functions though, none of my code (that I can see, anyway).

If I 'run' from the debugger, my hitherto-paused process completes.

debugger listening on port 5858
2013-10-31 15h41m21s GPS Module 1 2110_WIMMERA HWY _F_S1_0_125140 001.gps
->2013-10-31 15h41m21s GPS Module 1 2110_WIMMERA HWY _F_S1_0_125140 001.json
2013-12-16 12h12m49s GPS Module 1 2170_HYLAND HWY _F_S1_0_59840 001.gps
->2013-12-16 12h12m49s GPS Module 1 2170_HYLAND HWY _F_S1_0_59840 001.json

=> all-lines.json
vagrant@vagrant-ubuntu-trusty-64:/vagrant/test$

The node-debug process is still running, and I have to kill it in order to be able to run coffee again. Awkward.

1

There are 1 answers

3
Brad On

Yes, you can debug any Node.js application, even if it starts no server at all. Starting node-debug starts up its own web server to handle the application.

I don't see anywhere you are actually running node-debug. It looks like you're connecting your browser to the debugging protocol port, and not node-debug itself. Node-debug is a web application that then connects to the debugging port of your application.