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

Heads up: fs.createWriteStream will cause a memory leak #1042

Open
krystianfowler opened this issue May 24, 2024 · 3 comments
Open

Heads up: fs.createWriteStream will cause a memory leak #1042

krystianfowler opened this issue May 24, 2024 · 3 comments

Comments

@krystianfowler
Copy link

  • Operating System: NixOS 23.11 (Tapir)
  • **Node.js version:**v20.9.0
  • **fs-extra version:**11.2.0

I have encountered a memory leak that happens when calling fs.createWriteStream from node-fs-extra. Since fs-extra calls gracefu-fs directly for this method I have reported the issue here on the graceful-fs repo: isaacs/node-graceful-fs#248

Since the leak is in graceful-fs I'm adding an issue here mainly as a heads up to anyone looking for a possible cause of their production memory leaks.

The issue is easily solvable by replacing fs-extra calls to createWriteStream with the native node one from node:fs.

@EliotCodes
Copy link

EliotCodes commented Nov 28, 2024

How come no one has solved the issue yet 😢

@stanleyxu2005
Copy link

I'm wondering if graceful-fs library can be removed completely by replacing all
const fs = require('graceful-fs') with
const fs = require('fs').promises?

@RyanZim
Copy link
Collaborator

RyanZim commented Jan 27, 2025

@stanleyxu2005 As long as you're not opening so many files at once that you're getting EMFILE errors, fs/promises should work just fine.

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

No branches or pull requests

4 participants