You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
EMFILE: too many open files error occurs when there is a significantly large enough set of static files #8719
bugAn error in the Docusaurus core causing instability or issues with its executionclosed: wontfixA fix will bring significant overhead, or is out of scope (for feature requests)
I have read the console error message carefully (if applicable).
Description
I pulled javadocs for a large set of projects as a static asset in a docusaurus site. When running npm run build, the build fails on the Server build with:
[Error] Error: Failed to compile with errors.
at /.../docusaurus-site/node_modules/@docusaurus/core/lib/webpack/utils.js:180:24
at /.../docusaurus-site/node_modules/webpack/lib/MultiCompiler.js:554:14
at processQueueWorker (/../docusaurus-site/node_modules/webpack/lib/MultiCompiler.js:491:6)
at processTicksAndRejections (node:internal/process/task_queues:78:11)
I attempted to change the parallelism setting for webpack by using a custom plugin as noted in this ticket 5502; however, the contents of the config that get passed down within MultiCompiler within webpack do not put the parallelism at the correct level in order to change the setting. Even after hardcoding the default from Infinity within webpack to 1, the build still yielded the same errors.
Number of assets in my /static directory: 34620
Reproducible demo
No response
Steps to reproduce
install docusaurus
in site dir run "npm install"
create a directory under the site/static directory
copy a large set of files into the dir created
run "npm run build"
Expected behavior
The build would work the first time
Actual behavior
Repeated output of "EMFILE: too many open files" and build fails
Your environment
Public source code: n/a
Public site URL: n/a
Docusaurus version used: 2.3.1
Environment name and version (e.g. Chrome 89, Node.js 16.4): node v16.19.1, npm 9.5.1
Operating system and version (e.g. Ubuntu 20.04.2 LTS): Amazon Linux 2
I don't understand what you tried to change in Webpack and for what reason.
I do not have a public repo to show the problem, but the steps should be pretty straight forward. Just create a new docusaurus site and copy around 35000 files into the static directory and try to build. I have not tried it on another OS, but I realize it is an OS limit problem. I do not believe it is unique to this OS though. I don't believe the docusaurus build should fail if this file limit is exceeded. The build should be able to handle a large number of static assets.
I tried to change webpack because the stack trace shows it died in webpack. And searching the webpack issues they have noted this problem several times over the years and put in options for limits to prevent it for large projects. See 31643166
but the steps should be pretty straight forward. Just create a new docusaurus site and copy around 35000 files into the static directory and try to build.
Can you do this then, and make sure you reproduce it consistently?
I have not tried it on another OS, but I realize it is an OS limit problem. I do not believe it is unique to this OS though. I don't believe the docusaurus build should fail if this file limit is exceeded. The build should be able to handle a large number of static assets.
Some OS have limits that you often need to raise for various use-cases, I don't think we can do anything about it. I can tell you that to get large code projects to run properly in my IDEs I had to tweak these limits many times, and that's fine. If you don't agree with your OS defaults, then you should ask your OS provider to change those defaults. It's quite unlikely we will be able to solve it unless it's clearly identified as a bug in Docusaurus (ie it fails for all OS no matter the increase of limits we attempt to do).
I can reproduce this consistently, though I did not try other operating systems:
npx create-docusaurus@latest my-website classic
cd my-website/static
mkdir stuff
cd stuff
for i in seq 1 35000; do echo "$i" > index_$i.html; done
cd ../..
npm install
npm run build
I was able to get around the issue by post copying the static assets into the build directory after the build happened. This is not ideal though because i had to disable the broken links (onBrokenLinks: 'warn') check which has the downside of now I won't catch any broken links ahead of time. While i can change the OS limit, it doesn't really solve the problem but moves the upper limit. The default limit is 1024 (ulimit -n) on amzn2. I suspect the problem stems from parallel copies of the static assets which at 35k is a lot of things trying to copy at the same time. I still think there should be an option to set that limit somewhere. I did not dig far enough to figure out how docusaurus is performing the copy from the static dir to the build dir.
I can reproduce this consistently, though I did not try other operating systems:
I run your commands, and can't reproduce
While i can change the OS limit, it doesn't really solve the problem but moves the upper limit.
I don't agree here. Sometimes the default os values are not good enough for what you want to do.:
my IDE has a low JVM memory by default, I have to increase it to open the Docusaurus project
the default nodejs memory is quite low and many programs require to increase it (including docusaurus sites quite often)
dev servers of large projects often require to increase FS system limits so that it's possible to watch edits on thousands of files
The default limit is 1024 (ulimit -n) on amzn2.
That seems very low to me. I remember having to increase this limit so many times for various reasons this last decade.
Similarly, if you set a limit of 1, don't be surprised if nothing works on your computer.
We may not agree here but I'm going to close this issue: I don't see how we could solve this on the Docusaurus side (it is maybe possible but we won't do this because there are much lower hanging perf fruits to handle. Feel free to suggest technical solutions if you want and submit PRs if you know how to solve this).
Some limits are meant to be increased, and that's fine.
As an example, my MacOS comes with a "hard limit" of "unlimited". That's probably one reason devs like MacOS: they have better default and just work, not like custom EC2 instances.
bugAn error in the Docusaurus core causing instability or issues with its executionclosed: wontfixA fix will bring significant overhead, or is out of scope (for feature requests)
Activity
slorber commentedon Mar 1, 2023
That would help to have a repro otherwise it's quite unactionable on our side.
Have you tried this on another system.
The error looks related to your system, cf https://stackoverflow.com/questions/8965606/node-and-error-emfile-too-many-open-files
It may not happen if you change system settings or try to run this on another computer. You'll find many related issues if you google that error message, have you tried the suggested solutions?
I don't understand what you tried to change in Webpack and for what reason.
MrFunions commentedon Mar 1, 2023
I do not have a public repo to show the problem, but the steps should be pretty straight forward. Just create a new docusaurus site and copy around 35000 files into the static directory and try to build. I have not tried it on another OS, but I realize it is an OS limit problem. I do not believe it is unique to this OS though. I don't believe the docusaurus build should fail if this file limit is exceeded. The build should be able to handle a large number of static assets.
I tried to change webpack because the stack trace shows it died in webpack. And searching the webpack issues they have noted this problem several times over the years and put in options for limits to prevent it for large projects. See 3164 3166
slorber commentedon Mar 2, 2023
Can you do this then, and make sure you reproduce it consistently?
Some OS have limits that you often need to raise for various use-cases, I don't think we can do anything about it. I can tell you that to get large code projects to run properly in my IDEs I had to tweak these limits many times, and that's fine. If you don't agree with your OS defaults, then you should ask your OS provider to change those defaults. It's quite unlikely we will be able to solve it unless it's clearly identified as a bug in Docusaurus (ie it fails for all OS no matter the increase of limits we attempt to do).
MrFunions commentedon Mar 2, 2023
I can reproduce this consistently, though I did not try other operating systems:
npx create-docusaurus@latest my-website classic
cd my-website/static
mkdir stuff
cd stuff
for i in
seq 1 35000; do echo "$i" > index_$i.html; donecd ../..
npm install
npm run build
I was able to get around the issue by post copying the static assets into the build directory after the build happened. This is not ideal though because i had to disable the broken links (onBrokenLinks: 'warn') check which has the downside of now I won't catch any broken links ahead of time. While i can change the OS limit, it doesn't really solve the problem but moves the upper limit. The default limit is 1024 (ulimit -n) on amzn2. I suspect the problem stems from parallel copies of the static assets which at 35k is a lot of things trying to copy at the same time. I still think there should be an option to set that limit somewhere. I did not dig far enough to figure out how docusaurus is performing the copy from the static dir to the build dir.
slorber commentedon Mar 2, 2023
I run your commands, and can't reproduce
I don't agree here. Sometimes the default os values are not good enough for what you want to do.:
That seems very low to me. I remember having to increase this limit so many times for various reasons this last decade.
Similarly, if you set a limit of 1, don't be surprised if nothing works on your computer.
We may not agree here but I'm going to close this issue: I don't see how we could solve this on the Docusaurus side (it is maybe possible but we won't do this because there are much lower hanging perf fruits to handle. Feel free to suggest technical solutions if you want and submit PRs if you know how to solve this).
Some limits are meant to be increased, and that's fine.
As an example, my MacOS comes with a "hard limit" of "unlimited". That's probably one reason devs like MacOS: they have better default and just work, not like custom EC2 instances.
https://wilsonmar.github.io/maximum-limits/