Ziv-Barber / officegen

Standalone Office Open XML files (Microsoft Office 2007 and later) generator for Word (docx), PowerPoint (pptx) and Excell (xlsx) in javascript. The output is a stream.
MIT License
2.65k stars 471 forks source link

EMFILE: too many open files #338

Open cardin opened 4 years ago

cardin commented 4 years ago

Environment

  1. node -v: 10.14.1
  2. npm -v: 6.4.1
  3. npm ls officegen: 0.6.3
  4. Operating system: RHEL 7.4x64
  5. Microsoft Office version: N.A.
  6. Problem with Powerpoint, Excel or Word document: Word document

Steps to Reproduce

  1. Run .addImage(...) for 8000 times
  2. Run .generate(...)

Expected Behavior

Should not crash.

Actual Behavior

officegen will crash with error EMFILE: too many open files


Note that changing Linux file open limits in /etc/system/limits.conf does not help.

To fix this issue, please switch to using graceful-fs for your generation function

  1. npm install graceful-fs
  2. Go to ./node_modules/officegen/lib/core/index.js
  3. Change the line with require("fs") to require("graceful-fs")

.: Success!