How to show stack trace information when there's an error in an api (written in nodejs)? I used curl to issue a post btw.
I tried node's cli parameter, --stack-trace-limit, but nothing shows up except an unfriendly one liner error message. I could use console.* and debugger lines in the code but it's too time consuming. I tried node-inspector. While it has a nice GUI, it crashes quite. I reckon there has to be an easier way??
Thx. J
Without seeing some code it is hard to answer specifically. However you can also get a stack trace using
var stack = new Error().stack
kill -SIGUSR2 [pid] to a running node process to generate a heapdump which can then be viewed in the Chrome developer tools by opening up the profiles tab and right clicking in the left pane and choosing Load Profilenode debug module_name.js Then anywhere you have debugger; statement in your code will cause the debugger to break thereThe way you write asyncronous node.js code can have a big effect on the ease of debugging. Named functions are good, anonymous highly nested functions are bad. Check out http://callbackhell.com/ for a good guide on how to write clean debuggable node.js code