Debugging an exception using nodejs

I am parsing a large number of files using nodejs. In my process, I parse audio files, video files, and the rest.

The function for analyzing files is as follows:

/**
* @param arr : array of files objects (path, ext, previous directory)
* @param cb : the callback when every object is parsed, 
*             objects are then throwed in a database
* @param others : the array beeing populated by matching objects
**/
var parseOthers = function(arr, cb, others) {

    others = others === undefined ? [] : others;

    if(arr.length == 0)
        return cb(others); //should be a nextTick ?

    var e = arr.shift();

    //do some tests on the element and add it
    others.push(e);
    //Then call next tested callImediate and nextTick according
    //to another stackoverflow questions with no success
    return parseOthers(arr, cb, others);
});

Full code here (take care of it)

Now with approximately 3565 files (not so many), the script will catch the exception "RangeError: Maximum call stack size exceeded", without tracing.

What I tried:

  • I tried to debug it with node-inspectorand node debug script, but it never freezes, as if it worked without debugging (does the assembly debug the stack?).
  • I tried to process.on('uncaughtException')catch an exception without success.

I have no memory leak.

How can I find an exception trace?

Change 1

--stack_size . ?

( 1300)

2

:

$ node --v8-options | grep -B0 -A1 stack_size

( kBytes) 984.

3

:

  • .
  • ,
  • ,

, nodejs, ...

+3
2

Stackoverflow . , .

( ):

JXcore ( Node.JS) . , 1 . 1 1 .

var myTask = function ( args here )
{
    logic here
}

for(var i=0;i<LIST_OF_THE_FILES;i++)
    jxcore.tasks.addTask( myTask, paramshere, optional callback ...    

, ;

var myTask = function ( args here )
{
    require('mytasketc.js').handleTask(args here);
}

for(var i=0;i<LIST_OF_THE_FILES;i++)
    jxcore.tasks.addTask( myTask, paramshere, optional callback ... 

V8.

,

Javascript-

+4

- . , , , . APPROXIMATE, , :

var parseElems = function(arr, cb) {
    var result = [];
    arr.forEach(function (el) {
         //do some tests on the element (el)
         result.push(el);
    });

    cb(result);
});
+1

All Articles