rook2pawn/node-filecompare

EMFILE, too many open files

blowsie opened this issue · 1 comments

Im using asnyc (https://www.npmjs.org/package/async) - eachSeries to iterate through my files one at a time, and also logging open and close just for sanity. However after a 1021 files, I get the following error.
Error: EMFILE, too many open files

I'm guessing something is not being closed properly by the plugin?

async.eachSeries(self.items, function (value, callback) {
    console.log('open')
    fc(value.originalFile, value.targetFile, function (isEqual) {
        if (!isEqual) {
            self.invalidate(report);
        }
        console.log('close');
        callback();
    });

}, function (err) {
    if (err) {
        console.error(err)
    }
    console.log('done')
});

open
close
open
close
open

Error: EMFILE, too many open files *****************************
at Object.fs.openSync (fs.js:438:18)
    at Object.exports.file (c:\Users\Sam\Desktop\node-dir-compare\node-dir-compare\node-dir-compare\node_modules\filecompare\lib\index.js:5:17)
    at module.exports (c:\Users\Sam\Desktop\node-dir-compare\node-dir-compare\node-dir-compare\node_modules\filecompare\index.js:4:18)
    at c:\Users\Sam\Desktop\node-dir-compare\node-dir-compare\node-dir-compare\pro-compare.js:76:17
    at iterate (c:\Users\Sam\Desktop\node-dir-compare\node-dir-compare\node-dir-compare\node_modules\async\lib\async.js:149:13)
    at c:\Users\Sam\Desktop\node-dir-compare\node-dir-compare\node-dir-compare\node_modules\async\lib\async.js:160:25
    at null._onTimeout (c:\Users\Sam\Desktop\node-dir-compare\node-dir-compare\node-dir-compare\pro-compare.js:82:25)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

https://github.com/rook2pawn/node-filecompare/blob/master/lib/index.js#L35-L45

@blowsie
Sorry for the late reply. Files are now closed just before the callback.