angular-cli: Running `ng test` in windows fails with EMFILE error

Running ng test on Windows, with admin permissions, on a newly generated project fails with a Error: EMFILE: too many open files error.

Running ng serve and ng test --build=false in separate works though.

/cc @wardbell

OS: Windows 10

$ ng --version
angular-cli: 1.0.0-beta.5
node: 5.11.1
os: win32 x64

Reproduction steps:

ng new project
cd project
ng test

Result:

filipe.silva@DESKTOP-7ND6T3R MINGW64 /E/dev/testing/project (master)
$ ng test
Built project successfully. Stored in "dist/".
\ BuildingThe Broccoli Plugin: [BroccoliTypeScriptCompiler] failed with:
Error: EMFILE: too many open files, open 'E:\dev\testing\project\tmp\broccoli_type_script_compiler-input_base_path-sdKfbqXb.tmp\0\src\tsconfig.json'
    at Error (native)
    at Object.fs.openSync (fs.js:584:18)
    at Object.fs.readFileSync (fs.js:431:33)
    at BroccoliTypeScriptCompiler._loadTsConfig (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:123:34)
    at BroccoliTypeScriptCompiler._createServiceHost (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:158:25)
    at BroccoliTypeScriptCompiler.build (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:41:12)
    at C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\broccoli-caching-writer\index.js:152:21
    at lib$rsvp$$internal$$tryCatch (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1048:17)
    at lib$rsvp$$internal$$publish (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1019:11)
    at lib$rsvp$asap$$flush (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1198:9)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

The broccoli plugin was instantiated at:
    at BroccoliTypeScriptCompiler.Plugin (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\broccoli-plugin\index.js:10:31)
    at BroccoliTypeScriptCompiler.CachingWriter [as constructor] (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\broccoli-caching-writer\index.js:21:10)
    at BroccoliTypeScriptCompiler (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:26:49)
    at Angular2App._getTsTree (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\angular2-app.js:321:18)
    at Angular2App._buildTree (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\angular2-app.js:116:23)
    at new Angular2App (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\angular2-app.js:53:23)
    at module.exports (E:\dev\testing\project\angular-cli-build.js:6:10)
    at Class.module.exports.Task.extend.setupBroccoliBuilder (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\angular-cli\lib\models\builder.js:55:19)
    at Class.module.exports.Task.extend.init (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\angular-cli\lib\models\builder.js:89:10)
    at new Class (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\core-object\core-object.js:18:12)
    at Class.module.exports.Task.extend.run (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\angular-cli\lib\tasks\build-watch.js:17:16)
    at C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\addon\ng2\commands\test.js:69:46
    at lib$rsvp$$internal$$tryCatch (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1048:17)
    at lib$rsvp$$internal$$publish (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1019:11)
    at lib$rsvp$asap$$flush (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1198:9)


The Broccoli Plugin: [BroccoliTypeScriptCompiler] failed with:
Error: EMFILE: too many open files, open 'E:\dev\testing\project\tmp\broccoli_type_script_compiler-input_base_path-sdKfbqXb.tmp\0\src\tsconfig.json'
    at Error (native)
    at Object.fs.openSync (fs.js:584:18)
    at Object.fs.readFileSync (fs.js:431:33)
    at BroccoliTypeScriptCompiler._loadTsConfig (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:123:34)
    at BroccoliTypeScriptCompiler._createServiceHost (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:158:25)
    at BroccoliTypeScriptCompiler.build (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:41:12)
    at C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\broccoli-caching-writer\index.js:152:21
    at lib$rsvp$$internal$$tryCatch (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1048:17)
    at lib$rsvp$$internal$$publish (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1019:11)
    at lib$rsvp$asap$$flush (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1198:9)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

The broccoli plugin was instantiated at:
    at BroccoliTypeScriptCompiler.Plugin (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\broccoli-plugin\index.js:10:31)
    at BroccoliTypeScriptCompiler.CachingWriter [as constructor] (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\broccoli-caching-writer\index.js:21:10)
    at BroccoliTypeScriptCompiler (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\broccoli-typescript.js:26:49)
    at Angular2App._getTsTree (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\angular2-app.js:321:18)
    at Angular2App._buildTree (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\angular2-app.js:116:23)
    at new Angular2App (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\lib\broccoli\angular2-app.js:53:23)
    at module.exports (E:\dev\testing\project\angular-cli-build.js:6:10)
    at Class.module.exports.Task.extend.setupBroccoliBuilder (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\angular-cli\lib\models\builder.js:55:19)
    at Class.module.exports.Task.extend.init (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\angular-cli\lib\models\builder.js:89:10)
    at new Class (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\core-object\core-object.js:18:12)
    at Class.module.exports.Task.extend.run (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\angular-cli\lib\tasks\build-watch.js:17:16)
    at C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\addon\ng2\commands\test.js:69:46
    at lib$rsvp$$internal$$tryCatch (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1048:17)
    at lib$rsvp$$internal$$publish (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1019:11)
    at lib$rsvp$asap$$flush (C:\Users\filipe.silva\AppData\Roaming\nvm\v5.11.1\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1198:9)

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (9 by maintainers)

Commits related to this issue

Most upvoted comments

FYI, I changed my “test” npm-script to: ng build && ng test --build=false

That’s a good workaround until this is fixed.

I also have this issue and on Win10 and using ng test --watch=false as a workaround

I think it should be ng build && ng test --build=false --watch=false. There isn’t much point keeping the tester in watch mode if the sources don’t rebuild.

I still think separate ng serve + ng test processes are good for running tests in watch mode whereas the npm script change is better for running it once.

Further investigation shows that the problem occurs because of karma serving the files in dist/vendor/.

Effectively, the process is watching those files files twice - once for rebuilding them and once for testing them.

I don’t have a solution for this at the moment.