fix(runtime): make nofile soft limit configurable - #77587
Conversation
Production validation + cherry-pick noticeWe reproduced the macOS soft-256 EMFILE path on a multi-profile Desktop host and needed this floor in the field. Cherry-picked into #78873 (author commits preserved:
If maintainers prefer this PR to land first on its own, that’s ideal — #78873 can then drop the cherry-picks and keep only the startup-reap commit. Happy to rebase either way. |
|
Merged via PR #83406 — your commits were cherry-picked onto current main with your authorship preserved in git log (rebase merge). Thank you for the contribution! The omnibus combined the WAL read-connection pool (#76700), the configurable nofile floor (#77587), the parent-death watchdog (#73066), the Desktop-boot orphan serve reap incl. the backend.lock.json spare-guard (#78873), and the orphan gateway reap (#78312). All pieces were live-tested end-to-end: real orphaned processes reaped on actual Desktop boot with a lock-owned backend surviving, 151→9 connections under 150 reader threads, and zero fd growth over 800 requests against a live serve. |
What does this PR do?
Adds one shared, configurable
RLIMIT_NOFILEsoft-limit floor for Hermes' long-running gateway and dashboard/serve processes.This closes the macOS Desktop SSH gap where
hermes serve --isolatedinherits a soft limit of 256. Under file-descriptor pressure that produced[Errno 24] Too many open filesand cascading auth/session/provider failures even with only a few visible agents.Configuration
40960,false, ornull: disable the adjustmentsetrlimit: safe no-op; startup continuesThe implementation uses the canonical profile-aware
load_config_readonly()path, including managed-scope overlays. It does not add an environment-variable side channel.Startup surfaces
gateway.run.start_gateway()— applied before gateway initializationhermes_cli.main.cmd_dashboard()— applied after--status/--stopearly exits and before web-server imports/state; covers Desktop SSHhermes serve --isolatedPrior art and scope
Contributor
Type of change
Related issue
Fixes #77573
Related: #30230, #30234, #50494, #75269, #75322
Testing performed
Real macOS subprocess probes:
(256, unlimited)→(4096, unlimited)512:(256, unlimited)→(512, unlimited)0: remains(256, unlimited)Real candidate CLI on a throwaway profile:
The test suite directly covers:
0/false/nullopt-outresourcemodulegetrlimitfailuresetrlimit--status/--stopnon-mutationBackward compatibility
No migration is required. Existing configs receive the default through Hermes' normal deep-merge behavior. The operation is best-effort and never lowers an existing limit. Users can opt out with
runtime.nofile_soft_limit: 0(alsofalseornull).Checklist