-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Libsass/Too many files error on big sites when running server on MacOS #12649
Comments
I have few public websites (with average 35k -50k pages) having this issue on Mac (and not having with Netlify build). Finally I suspected that it cannot be malformed file, tried to reproduce, and reproduced. |
I started encountering this error a few weeks ago and did a lot of research and spent many hours on it:
Now, we documented it which is a good thing ;) No need to waste time on it, I agree, it may unpredictably disappear in some new versions. However, unfortunately, building by 20x smaller segments also fails with same error message... in Linux, I'd assume that |
OK, I can reproduce this. The odd thing is that even
Fails with ...
This doesn't make sense, but it's certainly easier to reason about when having the deps vendored. |
I can imagine weird path being generated by broken platform-specific tools, such as |
I think I'm running into this on my M1, as well. I'm working on the docs for O3DE, which works on my Linux machine, and builds with |
In my specific case, I was trying to "isolate" issue and found even exact number of files / threshold after which it happens (but I lost this number) Can you check please your total number of files (including pagination and aliases)? |
I tried O3DE too, number of files above 40,000; "threshold" which I found was around 37,000
I tried |
I deleted folders from "a" to "h" in (and I tried to set explicitly |
It's definitely something different within Hugo, but that's apparently platform specific. I pulled Hugo version 0.105.0 the other day (what the O3DE docs are currently built on; yeah, I know it's ancient, I currently have red tape in my way), and it works fine and builds nice and fast. I'm going to toy around with Hugo versions, so I can at least narrow down what version triggers it, though I'm wondering if it's something to do with the lib/dart Sass handling changes that've happened over the past year or so. |
OK, sorry for the late follow up, I have some time tomorrow and will have another look at this mystery error. |
Okay, so I think I found the issue, at least enough to point you in the right direction to fix it. I ran through old versions and found that, at least for my setup, 0.115.3 is the latest version that Strangely, if I replicate what Fuad did, and delete A-H from the To try to further isolate things, I tossed the api folder into my blog repo, which doesn't use Bootstrap, but a fork of the Dream/Dream Plus theme, which imports its big dependencies from CDNs, and uses vanilla CSS on the local side. That pushed its file count well above 40k, and I'm able to serve it just fine, as demonstrated here: I also toyed around with adding a toCSS function (copied from the docs) into a partial on my blog, and even with 40k files, it also serves fine. This says to me that the issue is deeper, but not OS-level deep. Something I noticed was that the docs are explicitly setting Okay, so that must mean it's a libsass thing, right? Well...not quite. Every version of Hugo I'm using is using the same version of libsass, so if it was just a libsass thing, then the behavior wouldn't change across Hugo versions. That means it's likely an interaction between Hugo and libsass. In looking at what did change between 115.3 and 115.4, I found this change, which seems at least from a cursory look through the release notes, to be the most likely culprit, since it's the only one that appears to be dealing with file pathing. However, I'm not at all familiar with the details of the inner workings of Hugo, so it's entirely possible that it was either an unrelated change, or one that didn't make it into the release notes. Regardless, I hope this helps pinpoint the root cause. |
OK, I finally found some time to get to the bottom of this. After digging into the C++ code in Libsass I found that it fails to open with the error code meaning This is related to Hugo's file watcher on MacOS. Libsass is deprecated so I'm not sure I'm going to spend time patching it to improve the error handling, I'll think about this. There are some OS settings related to getting rid of the "Too many open files", but my recommended workaround is to do:
Or something for these biiiig sites. |
I tried to run in separate terminal, with On Mac, default is 256; on Linux, 1024 (?); and it seems default setting on Linux works (I didn't test on Linux) But then, we can reproduce the same issue on Linux, by setting |
@bep Did you see any indication for why newer versions of Hugo fail with the error, but older ones don't, even when they all report the same version of libsass? Also, why are static files being opened (or at least "opened" as far as libsass and the OS are concerned) during this processing? |
Given that this problem seems to be related to LibSass, I can't think of a good reason to spend any time on it. LibSass was EOL'd 4 years ago. |
@ShaunaGordon This issue is not introduced by a code change in Hugo or Hugo's library, I double checked that. My best guess is that MacOS has changed its |
Now, with "smaller" site I don't have any issue:
Very fast, great improvements! |
The only issue with (@razonyang - to confirm, I use |
…" exception In Hugo we have had mysterious and hard-to-debug error reports about faliling imports on MacOs for files that's obviously there. Instead of just failing with a general error, we now throw a more detailed error message. From the Hugo side it looks like: ``` Error: error building site: TOCSS: failed to transform "hb/scss/index.scss" (text/x-scss): "<stream>:1:1": error reading file "/Users/bep/dump/large-site-test/_vendor/github.com/twbs/bootstrap/scss/_functions.scss": Too many open files ``` See gohugoio/hugo#12649
@FuadEfendi I reopened this; I guess this issue is annoying enough and very hard to debug for end users to warrant a one-line patch in libsass, so I have added this in bep/golibsass#12 which I will eventually pull into Hugo. |
…" exception In Hugo we have had mysterious and hard-to-debug error reports about faliling imports on MacOs for files that's obviously there. Instead of just failing with a general error, we now throw a more detailed error message. From the Hugo side it looks like: ``` Error: error building site: TOCSS: failed to transform "hb/scss/index.scss" (text/x-scss): "<stream>:1:1": error reading file "/Users/bep/dump/large-site-test/_vendor/github.com/twbs/bootstrap/scss/_functions.scss": Too many open files ``` See gohugoio/hugo#12649
Patch borrowed from sass/libsass#3183 by @tom-un See See gohugoio/hugo#12649
Patch borrowed from sass/libsass#3183 by @tom-un See See gohugoio/hugo#12649
Patch borrowed from sass/libsass#3183 by @tom-un See See gohugoio/hugo#12649
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes
Please see discussion at https://discourse.gohugo.io/t/hugo-embedded-web-server-limitations-error-tocss/50543 and https://github.com/orgs/hbstack/discussions/68
This is test site with randomly generated 40,000 files:
https://github.com/tokenizer-inc-canada/large-site-test
hugo server
command fails withError: error building site: TOCSS: failed to transform ...
error message, andhugo
command fails with different error message.Another user, @razonyang tried on Windows, and it doesn't fail.
I tried on MacBook M1 Pro with 64G, and on MacBook Air M1, and it fails on both, tried with 0.127.0, 0.128.1, 0.128.2.
If I randomly delete any 10,000 files, build doesn't fail.
With configured "segments" feature, when I try to build small subset, build still fails, and fails in faster time.
The text was updated successfully, but these errors were encountered: