3

My co-workers and I have written a node.js application. I was assigned to debug an issue this week. The issue is that the application crashes every few days with this error:

events.js:0
(function (exports, require, module, __filename, __dirname) { // Copyright Joy
^
RangeError: Maximum call stack size exceeded

Unfortunately it doesn't print anything else.

What node.js methods and tools could I use with node.js to debug this issue? Our application is really huge (it powers the entire campus document finder) so we don't know where this error is happening exactly (there are many files of source code).

6
  • 1
    stackoverflow.com/questions/6095530/… Commented Oct 19, 2014 at 7:03
  • from the error it seems that an event emitter emits an event when this event is emitted, I mean that the event is triggered by itself, with some code example I could say more. Try node-inspector to debug Commented Oct 22, 2014 at 7:41
  • I had a very similar issue a while ago in a very simple app. Do not remember well, but I think it was even caused by event.js, as well. I had process.on('uncaughtException', ...) set but the error was not caught there. I was able to reproduce the error, but it did not make any sense (to me at least). I thought it was some node.js external bug, so start using an older version (0.8.x instead of 0.10.2x). The error disappeared. After a couple of weeks and reboots I decided to try 0.10.2x again. There was no error any more -- though my code was exactly the same as before. Commented Oct 23, 2014 at 13:09
  • See this post stackoverflow.com/questions/7663957/… Commented Oct 27, 2014 at 16:41
  • Some other approaches you might look in to are discussed here: stackoverflow.com/questions/591857/… Commented Oct 28, 2014 at 13:58

2 Answers 2

3
+100

From your description (that it crashes, predictably, every few days -- presumably after the same amount of time), it sounds like there may be a thread whose stack is growing over time through recursion. To see this, I'd wait for a day or so and then use ProcDump to force a core dump of whatever container application is actually executing the javascript. Open the core file up in something like WinDbg and look for the thread with the ridiculous number of stack frames -- that could shed some light on your problem.

Sign up to request clarification or add additional context in comments.

3 Comments

On my way home last night, I realized this probably won't work, as the javascript is interpreted, not compiled, so the container running it won't have the sort of stack trace I was imagining, but this approach may not be a total loss. After you collect the core dump, try running it through the utility "strings", which will pull out the ASCII strings in the dump. I would expect that a javascript interpreter would have copies of the interpreted line in memory, and that if it were recursing, there would be a LOT of copies of that line -- so look for thousands of copies of the same js line.
Hi Randy, I didn't quite figure it out yet but I'll award you the bounty. I and my co workers will try to figure it out using your method. Thanks.
Thank you bodacydo, and good luck. One more note: if the system you're using is Unicode, and not ASCII, then you'll need to use a strings utility that understands Unicode -- I'd suggest the Sysinternals strings.exe available from Microsoft.
1

If you have no tools, create one. You should count function calls by values, I mean you should insert something like this inside the function:

function(...) {
  callCounter[module]++;
  console.log("module:",module,"count:",callCounter[module]);
    ...
  callCounter[module]--;
} // fn()

Yes, it will flood the screen, (EDIT:) so you may capture it. (This half sentence disappeared somehow, re-added days later.)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.