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

🐛 BUG: Windows+node:fs=> ALL Pages uploads/updates fail with 2000+ files [ERROR EMFILE] #1586

Closed
torcd opened this issue Jul 30, 2022 · 1 comment · Fixed by #5632 or #6012
Closed
Labels
bug Something that isn't working pages:validated A validated Pages issue pages Relating to Pages

Comments

@torcd
Copy link

torcd commented Jul 30, 2022

System tested

OS: Windows 64-bit
pm: nvm-windows
node.js: 16.7.0 (lowest supported), 16.16.0 (lts), 17.9.0, 18.5.0, 18.7.0 (latest), likely all versions affected
wrangler: 2.0.17, 2.0.23, likely all versions >2.0.6 affected
dependencies: all updated to "wanted" versions
ERROR src: -node:fs, -chokidar, -wrangler pages publish/upload code (eg lack of graceful fs queuing/retries)

Issue:

On win64, when publishing a few thousand files via wrangler pages publish, the uploads fail due to chronic ERROR EMFILE: too many files open '<C:\path\to\last\read\file>' errors.

The uploads either fail:

  1. during the dir walk/read/check stage if a previous deployment exceeds [6000-8000] files -> thus, one can't reliably update even a single file if larger previous deployments went through

OR

  1. during the upload stage when the total batch of files is in the [2K-4K]+ range -> ie, even the first deployment will fail if you start with a larger batch

Similar bugs/fixes elsewhere:

#141 chokidar: Use graceful-fs to avoid EMFILE?
#624 IPFS: upload directory with subdirectories [WIP]

Potential Fix/Solution:

The bug likely stems from use of the core node fs module and how files are watched and read in the pipeline. While chokidar+fsevents might be preventing EMFILE errors on Mac, no such mitigations appear to be used on Windows systems. Instead of queuing/waiting/retrying, the uploads fail entirely once a single EMFILE error is thrown, rendering Pages projects with a few thousand files impossible to maintain even though wrangler technically allows 20,000 files per upload. :((

Can a test build with graceful-fs +wrangler publish/upload code fs replacements be temporarily made available at least until a permanent Windows-specific fix is released? Thanks.

@torcd torcd added the bug Something that isn't working label Jul 30, 2022
@GregBrimble GregBrimble added the pages Relating to Pages label Aug 2, 2022
@nprogers nprogers added the pages:validated A validated Pages issue label Aug 3, 2022
@Cherry
Copy link
Contributor

Cherry commented Nov 6, 2022

Ran into this myself today with a large project. graceful-fs seems to be a good drop-in replacement to queue up the calls and more gracefully handle EMFILE errors.

horo-fox added a commit to horo-fox/workers-sdk that referenced this issue Apr 17, 2024
petebacondarwin pushed a commit to horo-fox/workers-sdk that referenced this issue May 20, 2024
RamIdeas pushed a commit that referenced this issue Jun 6, 2024
* Potentially fix #1586

* Rewrite comment

Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>

* Run prettier (oops)

---------

Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working pages:validated A validated Pages issue pages Relating to Pages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants