jprichardson / node-fs-extra

Node.js: extra methods for the fs object like copy(), remove(), mkdirs()
MIT License
9.44k stars 776 forks source link

Fix exposed fs stream classes being monkey patched by graceful-fs #990

Closed francisconeves97 closed 1 year ago

francisconeves97 commented 1 year ago

Hey!

I am opening this PR because I run into an issue while using a library that uses this fs-extra (serverless-esbuild).

The serverless-esbuild library uses the fs.createWriteStream API to create a new stream (ref) and listens to the 'open' event to perform some logic and close the stream. With my node version (v16.14.0), the 'open' event was never being triggered.

After digging a little bit, I tried changing the importing createWriteStream from fs instead of fs-extra, which solved the issue.

It seems that fs-extra exposes the createWriteStream function from graceful-fs and graceful-fs had this issue some time ago: https://github.com/isaacs/node-graceful-fs/issues/170 which seems related to the problem I observed

I am opening this PR to upgrade the graceful-fs dependency, to fix the same bug on upstream consumers of this library

francisconeves97 commented 1 year ago

I am closing this because I realize that this can be solved by changing the locked versions under the dependency tree, since here we don't fix the minor version