Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: EMFILE: too many open files - Processing a large volume of SVGs on Windows #2094

Open
futuremotiondev opened this issue Mar 6, 2025 · 0 comments
Labels

Comments

@futuremotiondev
Copy link

Describe the bug
When processing a large amount of SVG files, I get the following error:

2025-03-06 15:22 C:\Users\username\Desktop\TestSVG> svgo -rf '.\BigSVG Full\'
Processing directory '.\BigSVG Full\':

Error: EMFILE: too many open files, open 'C:\Users\username\Desktop\TestSVG\BigSVG Full\Huge Set wSubfolder\SVG Various 01\1800 20px Icon Pack Grid 2.svg'
    at async open (node:internal/fs/promises:634:25)
    at async Object.readFile (node:internal/fs/promises:1238:14)
    at async Promise.all (index 8189)
    at async Command.action (C:\Users\username\AppData\Local\nvm\v23.9.0\node_modules\svgo\lib\svgo\coa.js:243:5)
    at async Promise.all (index 0)

To Reproduce
Steps to reproduce the behavior:

  1. Create a directory with a huge volume of SVGs and sub-directories also with a ton of SVGs. I can't give exact numbers since this error is random but my test directory that errors is called BigSVG Full and contains 87,591 Files and 933 Folders.
  2. Open Pwsh or whatever shell and run svgo -rf '.\BigSVG Full\'
  3. Error occurs.

Expected behavior
SVGO to properly manage parallel processing for large sets of SVGs.

Desktop (please complete the following information):

  • SVGO Version v3.3.2
  • NodeJs Version 23.9.0 x64
  • OS: Windows 10 Pro x64 22H2 (OS Build 19045.5555)

Additional context
I've seen other comments saying that using graceful-fs was a quick way to fix the issue but I'm not sure how to implement this fix exactly.

I am automating SVGO with Powershell, so if someone can recommend a good fix or simple patch that I can apply to SVGO that would be awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant