karma icon indicating copy to clipboard operation
karma copied to clipboard

ENFILE: file table overflow with Karma

Open abhipanda opened this issue 8 years ago • 19 comments

Hi Guys,

I am facing file table overflow issue while running the karma tests please help?

Details are mentioned here.

http://stackoverflow.com/questions/35873437/enfile-file-table-overflow-with-karma

Thanks, Abhi

abhipanda avatar Mar 08 '16 18:03 abhipanda

This issue is getting serious as more people are reporting it and we have no idea how it happened.

[08:44:36] 'karma' errored after 2.48 s [08:44:36] Error: ENFILE: file table overflow, scandir '/Users/Abhi/Documents/projects/test/src/app' at Error (native) at Object.fs.readdirSync (fs.js:808:18) at GlobSync._readdir (/Users/Abhi/Documents/projects/test/node_modules/karma/node_modules/glob/sync.js:275:41) at GlobSync._processGlobStar (/Users/Abhi/Documents/projects/test/node_modules/karma/node_modules/glob/sync.js:330:22) at GlobSync._process (/Users/Abhi/Documents/projects/test/node_modules/karma/node_modules/glob/sync.js:128:10) at new GlobSync (/Users/Abhi/Documents/projects/test/node_modules/karma/node_modules/glob/sync.js:46:10) at new Glob (/Users/Abhi/Documents/projects/test/node_modules/karma/node_modules/glob/glob.js:111:12) at /Users/Abhi/Documents/projects/test/node_modules/karma/lib/file-list.js:161:14 at Array.map (native) at [object Object].List._refresh (/Users/Abhi/Documents/projects/test/node_modules/karma/lib/file-list.js:153:37) at [object Object].List.refresh (/Users/Abhi/Documents/projects/test/node_modules/karma/lib/file-list.js:252:27) at [object Object].Server._start (/Users/Abhi/Documents/projects/test/node_modules/karma/lib/server.js:177:12) at [object Object].invoke (/Users/Abhi/Documents/projects/test/node_modules/karma/node_modules/di/lib/injector.js:75:15) at [object Object].Server.start (/Users/Abhi/Documents/projects/test/node_modules/karma/lib/server.js:101:18) at Gulp. (/Users/Abhi/Documents/projects/test/gulp/tasks/test-unit.js:53:12) at module.exports (/Users/Abhi/Documents/projects/test/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7) at Gulp.Orchestrator._runTask (/Users/Abhi/Documents/projects/test/node_modules/gulp/node_modules/orchestrator/index.js:273:3) at Gulp.Orchestrator._runStep (/Users/Abhi/Documents/projects/test/node_modules/gulp/node_modules/orchestrator/index.js:214:10) at Gulp.Orchestrator.start (/Users/Abhi/Documents/projects/test/node_modules/gulp/node_modules/orchestrator/index.js:134:8) at /Users/Abhi/Documents/projects/test/node_modules/gulp/bin/gulp.js:129:20 at nextTickCallbackWith0Args (node.js:419:9) at process._tickCallback (node.js:348:13)

abhipanda avatar Mar 09 '16 16:03 abhipanda

I don't think this is an issue with karma directly, it might be an issue with node-glob (which is known to be quirky on windows). The problem is I as long as I don't have a way to reproduce this I'm not sure what to do.

dignifiedquire avatar Mar 09 '16 16:03 dignifiedquire

Thanks. Just FYI ... I am running on Mac OS X El Capitan

abhipanda avatar Mar 09 '16 16:03 abhipanda

Oh sorry, yes you are right, not sure why I thought it was Windows related...

From the looks it might be sth tod with the jspm plugin. Have you tried removing it/different versions?

dignifiedquire avatar Mar 09 '16 16:03 dignifiedquire

I tried updating JSPM doesn't work, was getting npm deprecation warning in console for graceful-fs if that is relevant.

npm install jspm npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible. [email protected] node_modules/jspm ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ([email protected], [email protected]) ├── [email protected] ├── [email protected] ([email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected]) ├── [email protected] ([email protected]) ├── [email protected] ([email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected]) ├── [email protected] └── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])

abhipanda avatar Mar 09 '16 17:03 abhipanda

Hey Guys, As Abhi will know, i too found myself in the same boat today, oddly, the only one in my team we found it hard to spot the cause, but can confirm that the globbing was indeed spurning the error message and annoyingly didn't seem to have anything to do with open file limits (walked that path for a while sigh).

Stack answer i shared with Abhi here

In the end the main cause seemed to be if i used a glob pattern in the karma.config which contained a double asterisk (*/) in a folder that went further than a second level deep.

Then managed to replicate the error by using the node-glob directly, to generate the same error.

In the end, using the glob.sync route, and building the URL array myself worked around the issue. Hopefully this gives the author a clue into what he can do to fix. Cheers

kevcjones-archived avatar Mar 09 '16 20:03 kevcjones-archived

+1

After upgrading to ng2 beta 11, I'm too getting these errors.

{ [Error: ENFILE: file table overflow, scandir '/Users/git_repo/src/app'] errno: -23, code: 'ENFILE', syscall: 'scandir', path: '/Users/git_repo/src/app' }

playground avatar Mar 19 '16 03:03 playground

I have them on beta 9 (Yosemite)

laurelnaiad avatar Mar 19 '16 04:03 laurelnaiad

This should help: http://blog.mact.me/2014/10/22/yosemite-upgrade-changes-open-file-limit

fyodorvi avatar Mar 22 '16 03:03 fyodorvi

Any news on this? I get the error on a directory that only contains 1 level and 3 files in it...

Bolza avatar Apr 29 '16 12:04 Bolza

Any news on this issue? I have the same error. For information, I use MacOS 10.11.4.

said-abidi avatar May 09 '16 13:05 said-abidi

@Bolza @said-abidi

Run these in terminal:

echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
sudo sysctl -w kern.maxfiles=65536
sudo sysctl -w kern.maxfilesperproc=65536
ulimit -n 65536 65536    

Add this to ~/.bash_profile

ulimit -n 65536 65536

That's it.

Source: http://blog.mact.me/2014/10/22/yosemite-upgrade-changes-open-file-limit

fyodorvi avatar May 09 '16 21:05 fyodorvi

Getting this on ubuntu linux 16.04 as well,

ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 63562 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 65536 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 63562 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited

Pre-globbing the files worked, but ulimit changes didn't.

jamie-pate avatar Jun 30 '16 22:06 jamie-pate

Desactivate the cache for karma solved this issue (nocache = true in karma conf), but break the coverage using karma. Is there any way to solve this issue whitout increasing ulimit (we should not need it) and still use the cache?

said-abidi avatar Jul 06 '16 09:07 said-abidi

sudo launchctl limit maxfiles 16384 16384 && ulimit -n 16384 did it for me. I don't use Karma, but had similar issues with mup and the most recent Meteor release and packages I was using.

elie222 avatar Nov 15 '16 22:11 elie222

Cross-posting this here because it might help others, here's a solution to this issue by @abernix:

https://gist.github.com/abernix/a7619b07b687bb97ab573b0dc30928a0

SachaG avatar Jan 13 '17 01:01 SachaG

@elie222 saved me

JennieJi avatar Apr 21 '17 09:04 JennieJi

I have got a reproducible example for this issue, wanna see?

kof avatar Jun 14 '17 16:06 kof

@Bolza @said-abidi

Run these in terminal:

echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
sudo sysctl -w kern.maxfiles=65536
sudo sysctl -w kern.maxfilesperproc=65536
ulimit -n 65536 65536    

Add this to ~/.bash_profile

ulimit -n 65536 65536

That's it.

Source: http://blog.mact.me/2014/10/22/yosemite-upgrade-changes-open-file-limit

Thanks! Worked for me.

subodhk01 avatar Mar 17 '21 10:03 subodhk01