node-filewalker icon indicating copy to clipboard operation
node-filewalker copied to clipboard

stream event: Error: EMFILE: too many open files

Open strarsis opened this issue 8 years ago • 3 comments

When attaching a handler to stream event, recursively traversing a larger amount of files in a folder using node-filewalker, an error message occurs (usually at the same point (12114 files)):

[...]
Error: EMFILE: too many open files[...]
[...]

The ReadStream is even closed in the stream event handler, but this doesn't have an effect.

Windows 10 Home Premium x64, node v4.4.5, node-filewalker v0.1.3

strarsis avatar Jun 28 '16 22:06 strarsis

Did you try the maxPending option?

oleics avatar Jun 29 '16 00:06 oleics

Wouldn't it be a good feature if node-filewalker determines/find out retry what the limit currently is? Could node-graceful-fs be integrated?

strarsis avatar Jun 29 '16 01:06 strarsis

This was/is in fact the next feature that should be integrated:

https://github.com/oleics/node-filewalker/blob/58a0bff/lib/filewalker.js#L92

Linking detectedMaxOpen and maxPending if a flag is enabled should do the trick ;)

Using graceful-fs (which is a great node-module) could have negative impacts on performance.

oleics avatar Jun 29 '16 11:06 oleics