Compiler chokes on large source trees
With more than about 250 coffeescript files, a call to the compiler fails.
Repro:
In an empty directory:
Create 250 empty .coffee files
for i in seq 1 250; do touch $i.coffee; done
then try to compile them
coffee -c .
Observed: I've seen a couple of failures, all seemingly related to running out of file descriptors. One full run:
eric:coffee eric$ for i in `seq 1 250`; do touch $i.coffee; done
eric:coffee eric$ coffee -c .
(libuv) Failed to create kqueue (24)
(libuv) Failed to create kqueue (24)
events.js:72
throw er; // Unhandled 'error' event
^
Error: write EBADF
at errnoException (net.js:901:11)
at WriteStream.Socket._write (net.js:643:26)
at doWrite (_stream_writable.js:221:10)
at writeOrBuffer (_stream_writable.js:211:5)
at WriteStream.Writable.write (_stream_writable.js:180:11)
at WriteStream.Socket.write (net.js:613:40)
at printLine (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:27:27)
at /usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:459:20
at fs.js:944:21
at Object.oncomplete (fs.js:107:15)
Expected: I would expect it to queue up some reasonable number of parallel files instead of opening everything at once, or to recover gracefully from the failure.
I searched for related issues and found several related to watch (e.g. #1537 and #2004 ) which have been closed as non-fixable due to hard OS limitations on number of open files, but for a compilation it seems like there should be no issue with just limiting the number of concurrent operations.
Would a patch for this be welcome?
A patch for this would be welcome ... but the easy fix is just to up your ulimit. You often have to do that anyways, these days.