Repository navigation
gulp test.unit.js failing on Windows with Error: EMFILE: too many open files #4525
Copy link
Copy link
Closed
Labels
area: build & ciRelated the build and CI infrastructure of the projectRelated the build and CI infrastructure of the projecteffort1: hourstype: bug/fix
Description
The issue appeared with the update to node 4.1.1, npm 2.14.5, Karma 0.13.10, etc.
After upgrading node and npm, and doing a clean npm install, running gulp test.unit.js raises the following error on 2 different machines (Windows 7 and Windows 10):
05 10 2015 18:53:26.961:ERROR [karma]: { [Error: EMFILE: too many open files, open 'D:\Github\angular_mlaval\node_modules\chokidar\node_modules\readdirp\stream-api.js']
errno: -4066,
code: 'EMFILE',
syscall: 'open',
path: 'D:\\Github\\angular_mlaval\\node_modules\\chokidar\\node_modules\\readdirp\\stream-api.js' }
Error: EMFILE: too many open files, open 'D:\Github\angular_mlaval\node_modules\chokidar\node_modules\readdirp\stream-api.js'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at Object.Module._extensions..js (module.js:451:20)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at readdir (D:\Github\angular_mlaval\node_modules\chokidar\node_modules\readdirp\readdirp.js:52:25)
at EventEmitter.<anonymous> (D:\Github\angular_mlaval\node_modules\chokidar\lib\nodefs-handler.js:353:5)
at EventEmitter.NodeFsHandler._handleDir (D:\Github\angular_mlaval\node_modules\chokidar\lib\nodefs-handler.js:402:18)
at EventEmitter.<anonymous> (D:\Github\angular_mlaval\node_modules\chokidar\lib\nodefs-handler.js:450:19)
at EventEmitter.<anonymous> (D:\Github\angular_mlaval\node_modules\chokidar\lib\nodefs-handler.js:455:16)
at FSReqWrap.oncomplete (fs.js:82:15)
Running gulp test.unit.js/ci raises:
05 10 2015 18:54:19.816:ERROR [karma]: { [Error: EMFILE: too many open files, open 'D:\Github\angular_mlaval\npm-shrinkwrap.json']
errno: -4066,
code: 'EMFILE',
syscall: 'open',
path: 'D:\\Github\\angular_mlaval\\npm-shrinkwrap.json' }
Error: EMFILE: too many open files, open 'D:\Github\angular_mlaval\npm-shrinkwrap.json'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.fs.readFileSync (fs.js:397:15)
at _checkCache (D:\Github\angular_mlaval\tools\npm\check-node-modules.js:41:26)
at checkNodeModules (D:\Github\angular_mlaval\tools\npm\check-node-modules.js:13:23)
at D:\Github\angular_mlaval\tools\check-environment.js:25:10
at ChildProcess.exithandler (child_process.js:194:7)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:817:16)
at Socket.<anonymous> (internal/child_process.js:319:11)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at Pipe._onclose (net.js:469:12)
Note that gulp test.unit.dart and gulp test.unit.cjs are working fine
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: build & ciRelated the build and CI infrastructure of the projectRelated the build and CI infrastructure of the projecteffort1: hourstype: bug/fix
Activity
IgorMinar commentedon Oct 5, 2015
there is an issue with tmp folder not being cleaned up properly #4441 which might be related. can you verify that you can repro this issue with tmp folder manually removed?
marclaval commentedon Oct 5, 2015
It doesn't help, investigating ...
marclaval commentedon Oct 5, 2015
Some more observations:
karma start karma-js.conf.jsworksgulp test.unit.js/ciworks when commenting out the./tools/check-environmentpart: https://github.com/angular/angular/blob/master/gulpfile.js#L47-L50gulp test.unit.jsworks when commenting out the watcher part: https://github.com/angular/angular/blob/master/gulpfile.js#L601-L606Could it be some kind of race condition on the filesystem access?
2 remaining items
alfonso-presa commentedon Oct 9, 2015
@Mlaval Your patch worked perfectly for me, thanks!
Is there any possibility of adding this patch to the master branch to fix the situation until karma/graceful-fs/node get's fixed? It's a little bit of a pain having that file always dirty in the local folder, but anyway is something I can live with, I guess (sigh).
alfonso-presa commentedon Oct 9, 2015
BTW just in case it gives you some more clues, what I was doing to run the tests (before applying your patch that is a lot much better), was watching only the
gulpfile.jsinstead of the full modules folder. This way it runs, so it seems like there are still some file handles avail (at least one :-) )....ericmartinezr commentedon Oct 16, 2015
Sorry for bumping this issue, but just upgraded to a.44 and I ran into this issue (prior to a.44 this didn't happen to me). I tried @Mlaval patch but doesn't work for me, instead of failing and crashing, it just throws the error message, pass it and gets stuck in a posterior step, here's part of the log http://pastebin.com/N0CZzPUm (It just get stuck in the last line). I even tried with giving more time to the setTimeout). I'm under Ubuntu 14.04.2 LTS (a VM, fwiw)
Edit
I just followed this comment computmaxer/karma-jspm#97 (comment), also I removed the patch.
I edited
/etc/security/limits.confand added (rebooted after this)Now it's working correctly
marclaval commentedon Oct 16, 2015
On Windows, still the same situation with latest master.
Upgrading to node 4.2.1 doesn't help
IgorMinar commentedon Oct 16, 2015
Marc, let's debug this after Angular Connect when I'm at your office.
On Fri, Oct 16, 2015, 5:15 AM Marc Laval notifications@github.com wrote:
fix(build): EMFILE error on Windows when executing JS unit tests
comdiv commentedon Nov 29, 2015
While it marked as closed I catch it in Windows 10 1511 build:
Don't understand what I have to do with it...
It's working with test.unit.js, but not with test.unit.js/ci
jfarid27 commentedon Dec 20, 2015
I'm not sure about the status of this bug, but this might be a Karma or Node issue. I was brought here trying to search for the same "too many files" issue, specifically using this project I started a few months ago. I'm having this problem now on a MacPro 2015 on OSX El Capitan, using Node 4.2.2 and npm 2.14.7. Along with this, it was tested on Karma 0.13.15. All the dependencies are the same in the package as well if anyone wants to try and recreate. It is strange that the project starts fine with the standard npm start, so I'm starting to be sure it's a Karma or Node issue somewhere around versions 0.13.x and 4.2.x. I'll try to get an update with Node 5 and see if it works out.
angular-automatic-lock-bot commentedon Sep 8, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.