0

Question regarding javascript debugging:

We have a mobile app, made with JavaScript and HTML. This app is running on the mobile platform (BlackBerry 10, Android, iOS) inside a web container.

There is another part of this application running on the remote server. This part is implemented also with JavaScript running on Node.js.

Assume there is some communication established between the client (JS on mobile) and the server (JS on Node.js) sides using e.g. REST.

The question I would like to know is if it is possible to seamlessly debug both sides at the same time. E.g. if I have a breakpoint on the mobile app client side, how would I be able to debug all the way to JS on the server side, if it’s possible at all.

Any suggestions would help.

user1607549
  • 1,109
  • 2
  • 11
  • 17
  • Are you able to run your app inside the Chrome browser? If so you could use Chrome's remote debugging functionality to set breakpoints and step through the code. It works very well. – Jeff Feb 14 '14 at 21:00
  • Yes, the app would be inside a chromium based web container. Would the remote debugging allow me to step through the server code running on nodejs? – user1607549 Feb 14 '14 at 21:04
  • Sorry, I'm not very familiar with node.js but I hightly doubt you can debug the server code with the same tool. You might take a look at [this post](http://stackoverflow.com/questions/1911015/how-to-debug-node-js-applications). Also it looks like you can even debug WebViews starting with Android 4.4 (KitKat). See [here](https://developers.google.com/chrome-developer-tools/docs/remote-debugging#debugging-webviews) – Jeff Feb 14 '14 at 21:08
  • So I guess as of right now, there is no known solution to seamless client server debugging available for node? – user1607549 Feb 14 '14 at 22:01

2 Answers2

0

You can use node-inspector on the server, then you'll have TWO instances, but the same debugger toolset.

If you're stepping through code client, and want to debug "into" the server, you must place a breakpoint in the server debugger before making the GET/POST from the client.

TIP: Get a three (at least two) monitor setup.

Lucio M. Tato
  • 4,720
  • 1
  • 28
  • 30
0

Using the node inspector is a good strategy for doing debugging, but it would also be good to supplement the debugger with logging.

Debugging will let you step through an event chain and examine values of variables and output of functions in that chain, but in production it won't give you insight into the steps or production conditions that lead to errors users are experiencing (i.e. Why do I have a null variable? Why is my response message wrong?) If you use debugging without logging you'll be trying to replicate the conditions in production that are causing an error, which is an inefficient (and usually futile) way of doing things.

I'd say the best way to implement what you want to do (solve issues taking into account client & server events that happen concurrently) is to implement an open source logging library like Log4j on both your server and your client and configure an appender to send the logs to a log aggregator like Loggly which gives you tools to analyze both client & server logs in the same place (rather than extracting log files from both devices manually).

Once you've done this, you'll be able to distribute your application out to testers and you'll be able to see what actions, application logs, and hardware/network conditions surround certain issues. With this data in hand you'll know a lot better what leads to certain bugs and can use that information to much more effectively use node-inspector to debug them.