fix: add http server timeouts to prevent fd exhaustion - #33
Merged
Conversation
Preview torn downThis PR's ephemeral environment was cleaned up.
Reopen the PR if you need to spin it back up. |
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.
Overview
The server started with
http.ListenAndServe, which has no connection timeouts, so idle and half-dead keep-alive connections were never closed. They leaked file descriptors over weeks until the process hit its 65k limit, stopped accepting connections, and took the whole API down. Gave the server explicit read, write, header, and idle timeouts so every connection has a bounded lifetime, and exempted the cache-db dump endpoint since it legitimately streams for longer. Added a file-descriptor monitor too, so the next slow climb pages through the notification channels at 80% of the limit instead of going dark at 100%.