fix(cli): bump open files limit on macOS and Linux#2106
Open
Conversation
This automatically bumps the maximum number of open files (NOFILE) to the hard limit. It prevents 'Too many open files (os error 24)' which happens easily on macOS due to its low default soft limit (256). Fixes #1248
5e0474d to
36de5a6
Compare
thomas-zahner
approved these changes
Mar 26, 2026
Member
There was a problem hiding this comment.
Seems to work on my machine 👍
So just it's my little comment below.
this branch
➜ ~ prlimit --pid $(pgrep lychee) --nofile
RESOURCE DESCRIPTION SOFT HARD UNITS
NOFILE max number of open files 524288 524288 files
master
➜ ~ prlimit --pid $(pgrep lychee) --nofile
RESOURCE DESCRIPTION SOFT HARD UNITS
NOFILE max number of open files 1024 524288 files
| // This is helpful because lychee opens many files concurrently during | ||
| // link extraction and checking, which can exceed the default limit | ||
| // of 256 open files on macOS. See https://github.com/lycheeverse/lychee/issues/1248 | ||
| #[cfg(any(target_os = "macos", target_os = "linux"))] |
Member
There was a problem hiding this comment.
Peeking inside the function I see the guard #[cfg(unix)] { ... } #[cfg(windows)] { Ok(lim) }. So I would remove our config guard completely. It's less code and will handle all cases for us, including all Unixes, not just macOS and Linux.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This automatically bumps the maximum number of open files (NOFILE) to the hard limit.
It prevents 'Too many open files (os error 24)' which happens easily on macOS due to its low default soft limit (256).
It addresses the issue originally mentioned in the comments, where users experience this during initial link extraction or link checking across multiple files.
Fixes #1248