Skip to content

fix(cli): bump open files limit on macOS and Linux#2106

Open
mre wants to merge 1 commit intomasterfrom
fix/1248-too-many-open-files-2
Open

fix(cli): bump open files limit on macOS and Linux#2106
mre wants to merge 1 commit intomasterfrom
fix/1248-too-many-open-files-2

Conversation

@mre
Copy link
Member

@mre mre commented Mar 26, 2026

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

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
@mre mre force-pushed the fix/1248-too-many-open-files-2 branch from 5e0474d to 36de5a6 Compare March 26, 2026 01:58
Copy link
Member

@thomas-zahner thomas-zahner left a comment

Choose a reason for hiding this comment

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

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"))]
Copy link
Member

@thomas-zahner thomas-zahner Mar 26, 2026

Choose a reason for hiding this comment

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

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.

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.

Too many open files (os error 24) on macOS

2 participants