Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 308 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I debug Node.js applications?

#21
A lot of great answers here, but I'd like to add my view (based on how my approach evolved)

## Debug Logs

Let's face it, we all love a good `console.log('Uh oh, if you reached here, you better run.')` and sometimes that works great, so if you're reticent to move too far away from it at least add some bling to your logs with [Visionmedia's debug][1].

## Interactive Debugging

As handy as console logging can be, to debug professionally you need to roll up your sleeves and get stuck in. Set breakpoints, step through your code, inspect scopes and variables to see what's causing that weird behaviour. As others have mentioned, [node-inspector][3] really is the bees-knees. It does everything you can do with the built-in debugger, but using that familiar Chrome DevTools interface.
If, like me, you use **Webstorm**, then [here][4] is a handy guide to debugging from there.

## Stack Traces

By default, we can't trace a series of operations across different cycles of the event loop (ticks). To get around this have a look at [longjohn][5] (but not in production!).

## Memory Leaks

With Node.js we can have a server process expected to stay up for considerable time. What do you do if you think it has sprung some nasty leaks? Use [heapdump][6] and Chrome DevTools to compare some snapshots and see what's changing.


----------


For some useful articles, check out

* [RisingStack - Debugging Node.js Applications](

[To see links please register here]

)
* [Excellent article by David Mark Clements of nearForm](

[To see links please register here]

)

If you feel like watching a video(s) then

* [Netflix JS Talks - Debugging Node.js in Production]()
* [Interesting video]() from [the tracing working group](

[To see links please register here]

) on tracing and debugging node.js
* [Really informative 15-minute video on node-inspector]()


Whatever path you choose, just be sure you understand how you are debugging

[![enter image description here][7]][7]

> It is a painful thing
> To look at your own trouble and know
> That you yourself and no one else has made it
>
> *Sophocles, Ajax*


[1]:

[To see links please register here]

[2]:

[To see links please register here]

[3]:

[To see links please register here]

[4]:

[To see links please register here]

[5]:

[To see links please register here]

[6]:

[To see links please register here]

[7]:
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through