1

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.

Steve Bennett
  • 114,604
  • 39
  • 168
  • 219

1 Answers1

0

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.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • Thanks - thought I was missing something. Still a bit confused though. I install node-inspector, and start it. It tries to listen on both 8080 and 5858 - the latter of which fails, because that's the port that my debugged application is listening on? What am I missing? – Steve Bennett Nov 28 '14 at 05:26
  • @SteveBennett I don't use CoffeScript, but I think all you need to do is run `node-debug` by itself **after** starting your app with `--debug-brk`. That works just fine for me when starting my app with Node.js directly. – Brad Nov 28 '14 at 05:29
  • 1
    If you start your app manually, don't use `node-debug` command, use `node-inspector` command [readme](https://github.com/node-inspector/node-inspector#command-line) – 3y3 Nov 28 '14 at 14:04