Skip to content

gulp test.unit.js failing on Windows with Error: EMFILE: too many open files #4525

Closed

Description

@marclaval

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

Activity

  1. added this to the alpha-39 milestone on Oct 5, 2015
  2. IgorMinar commented on Oct 5, 2015

    @IgorMinar
    Contributor

    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?

  3. modified the milestones: alpha-40, alpha-39 on Oct 5, 2015
  4. modified the milestones: alpha-40, alpha-41 on Oct 5, 2015
  5. marclaval commented on Oct 5, 2015

    @marclaval
    ContributorAuthor

    It doesn't help, investigating ...

  6. marclaval commented on Oct 5, 2015

    @marclaval
    ContributorAuthor

    Some more observations:

    Could it be some kind of race condition on the filesystem access?

  7. 2 remaining items

  8. alfonso-presa commented on Oct 9, 2015

    @alfonso-presa
    Contributor

    @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).

  9. alfonso-presa commented on Oct 9, 2015

    @alfonso-presa
    Contributor

    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.js instead of the full modules folder. This way it runs, so it seems like there are still some file handles avail (at least one :-) )....

  10. ericmartinezr commented on Oct 16, 2015

    @ericmartinezr
    Contributor

    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.conf and added (rebooted after this)

    * soft nofile 40000
    * hard nofile 40000
    

    Now it's working correctly

  11. marclaval commented on Oct 16, 2015

    @marclaval
    ContributorAuthor

    On Windows, still the same situation with latest master.
    Upgrading to node 4.2.1 doesn't help

  12. IgorMinar commented on Oct 16, 2015

    @IgorMinar
    Contributor

    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:

    On Windows, still the same situation with latest master.
    Upgrading to node 4.2.1 doesn't help

    —
    Reply to this email directly or view it on GitHub
    #4525 (comment).

  13. removed this from the milestone on Oct 27, 2015
  14. added 2 commits that reference this issue on Oct 27, 2015
    99f26dd
  15. comdiv commented on Nov 29, 2015

    @comdiv

    While it marked as closed I catch it in Windows 10 1511 build:

    [00:03:36] Using gulpfile D:\testrepo\angular\gulpfile.js
    [00:03:36] Starting 'test.unit.js/ci'...
    30 11 2015 00:03:38.200:ERROR [karma]: { [Error: EMFILE: too many open files, op
    en 'D:\testrepo\angular\npm-shrinkwrap.json']
      errno: -4066,
      code: 'EMFILE',
      syscall: 'open',
      path: 'D:\\testrepo\\angular\\npm-shrinkwrap.json' }
    Error: EMFILE: too many open files, open 'D:\testrepo\angular\npm-shrinkwrap.jso
    n'
        at Error (native)
        at Object.fs.openSync (fs.js:549:18)
        at Object.fs.readFileSync (fs.js:397:15)
        at _checkCache (D:\testrepo\angular\tools\npm\check-node-modules.js:41:26)
        at checkNodeModules (D:\testrepo\angular\tools\npm\check-node-modules.js:13:
    23)
        at D:\testrepo\angular\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:818: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)
    [00:03:38] 'test.unit.js/ci' errored after 1.53 s
    

    Don't understand what I have to do with it...
    It's working with test.unit.js, but not with test.unit.js/ci

  16. jfarid27 commented on Dec 20, 2015

    @jfarid27

    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.

  17. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  18. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions