fix(gateway): raise macOS launchd fd limit to 4096 in generated plist#26536
Open
aisaacsmitchell wants to merge 1 commit into
Open
fix(gateway): raise macOS launchd fd limit to 4096 in generated plist#26536aisaacsmitchell wants to merge 1 commit into
aisaacsmitchell wants to merge 1 commit into
Conversation
The default macOS per-process open-file limit is 256. The gateway spawns cron-job subprocesses concurrently; under load, file descriptors accumulate across parallel runs and exhaust the limit, causing every subsequent Popen() call to fail with EAGAIN / BlockingIOError. This crashes the gateway and all cron jobs silently until the service is manually restarted. Add HardResourceLimits and SoftResourceLimits (NumberOfFiles: 4096) to generate_launchd_plist() so every hermes gateway install/start/restart produces a plist with an adequate fd ceiling. Both keys are required: SoftResourceLimits is the effective runtime cap; HardResourceLimits is the ceiling the process is permitted to raise itself to. Setting only Soft leaves Hard at the OS default (256), so any call to setrlimit() that tries to raise the soft limit hits the hard wall and fails. 4096 matches the value recommended in the macOS developer documentation for long-running daemons and is consistent with what other gateway daemons (nginx, postgres launchd plists) use as a baseline. Adds two tests to TestLaunchdPlistReplace verifying the keys are present and appear exactly once each.
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.
What
Add
HardResourceLimitsandSoftResourceLimits(NumberOfFiles: 4096) togenerate_launchd_plist().Why
The default macOS per-process open-file limit is 256. The gateway spawns cron-job subprocesses concurrently; under load, file descriptors accumulate across parallel runs and exhaust the limit, causing every subsequent
Popen()call to fail withEAGAIN/BlockingIOError. This crashes the gateway and all cron jobs silently until the service is manually restarted.Both keys are required:
SoftResourceLimitsis the effective runtime cap.HardResourceLimitsis the ceiling the process is permitted to raise itself to viasetrlimit(). Setting onlySoftleavesHardat the OS default (256), so any code that callssetrlimit()to raise the soft limit hits the hard wall and fails.4096 matches the value recommended in the macOS developer documentation for long-running daemons and is consistent with what nginx, postgres, and other launchd-managed services use as a baseline.
How to test
Or:
pytest tests/hermes_cli/test_update_gateway_restart.py::TestLaunchdPlistReplace -vPlatforms tested
macOS (Sonoma 15.x, Apple Silicon). Change is plist-only — no effect on Linux (systemd) or Windows paths.