Skip to content

Support copyFile#199

Merged
isaacs merged 1 commit intoisaacs:masterfrom
ramosbugs:copyFile
Feb 5, 2021
Merged

Support copyFile#199
isaacs merged 1 commit intoisaacs:masterfrom
ramosbugs:copyFile

Conversation

@ramosbugs
Copy link
Copy Markdown
Contributor

This PR adds support for copyFile, which can also return EMFILE
errors. I'm currently experiencing this via a third-party build tool that
copies many copies in parallel using Promise.all.

This PR also augments the write-then-read test to additionally copy
the written files and ensure that they exist and have the expected
content.

Resolves #122.

@ramosbugs
Copy link
Copy Markdown
Contributor Author

ramosbugs commented Nov 7, 2020

To add a bit more context: the issue is arising while using Yarn v2's PnP functionality, which also patches fs. As I understand it, Yarn does this in order to transparently support its zipped-up (i.e., non-node_modules) storage of dependencies, while allowing arbitrary packages to read the zipped-up files using normal fs calls. Since those Yarn-internal implementations of copyFile (and other functions) use other fs methods directly (bypassing graceful-fs), they can run into EMFILE errors. See @yarnpkg/fslib for details.

Wrapping the "outer" copyFile call in graceful-fs would provide an opportunity to handle the EMFILE errors and retry.

PR-URL: isaacs#199
Credit: @ramosbugs
Close: isaacs#199
Reviewed-by: @isaacs
@isaacs isaacs closed this in b2aba81 Feb 5, 2021
@isaacs isaacs merged commit b2aba81 into isaacs:master Feb 5, 2021
@FeelyChau
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown

@manjaneqx manjaneqx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔌

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

Successfully merging this pull request may close these issues.

fs.copyFile is not supported

4 participants