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.

有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top