fix(ssh): keep github.com connection alive through slow pre-push hooks - #59
Merged
Merged
Conversation
…hooks git push opens the SSH connection to github.com before running the pre-push hook, then leaves it fully idle for the hook's entire duration. Under heavy concurrent machine load, hooks routinely took long enough that GitHub's idle-connection timeout closed the SSH session mid-hook — the push then silently failed to transfer after printing "Safe to push," with only a stray "Connection to github.com closed by remote host." to explain it. Reproduced 4x in one session before diagnosing via GIT_TRACE=1. ServerAliveInterval/CountMax keep the connection alive during that idle window.
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.
Summary
git pushopens the SSH connection to github.com before running the pre-push hook, then leaves it idle for the hook's entire duration.GIT_TRACE=1.ServerAliveInterval 30/ServerAliveCountMax 10on the github.com SSH host keeps the connection alive with active keepalives during that idle window instead of relying on it staying up passively.Test plan
GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git push— confirmed the SSH session opens before the hook and drops during itbash -n .ssh/config(repo's own CI check)🤖 Generated with Claude Code
https://claude.ai/code/session_01Y9rKLxddothnXEtY6KDziN