diff --git a/lib/gemini.js b/lib/gemini.js index 5f5c419b8..042bf68e1 100644 --- a/lib/gemini.js +++ b/lib/gemini.js @@ -7,6 +7,7 @@ const PassthroughEmitter = require('./passthrough-emitter'); const Promise = require('bluebird'); const q = require('bluebird-q'); const pluginsLoader = require('plugins-loader'); +const gracefulFs = require('graceful-fs'); const Config = require('./config'); const GeminiError = require('./errors/gemini-error'); @@ -25,6 +26,9 @@ const PREFIX = require('../package').name + '-'; require('http').globalAgent.maxSockets = Infinity; Promise.promisifyAll(require('fs-extra')); +// patch fs module prototype for preventing EMFILE error (too many open files) +gracefulFs.gracefulify(require('fs')); + const parseBrowsers = (browsers) => { return browsers && browsers.replace(/\s/g, '').split(','); }; diff --git a/package.json b/package.json index 17d2f5342..09853721b 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "gemini-configparser": "^0.1.1", "gemini-core": "^1.0.0", "gemini-coverage": "^1.0.0", + "graceful-fs": "^4.1.11", "handlebars": "^4.0.5", "inherit": "~2.2.1", "js-yaml": "^3.2.5",