Open
Description
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:
- 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. - Open Pwsh or whatever shell and run
svgo -rf '.\BigSVG Full\'
- 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.