Skip to content

fix(ssh): keep github.com connection alive through slow pre-push hooks - #59

Merged
github-actions[bot] merged 1 commit into
masterfrom
worktree-ssh-keepalive-github
Aug 29, 2026
Merged

fix(ssh): keep github.com connection alive through slow pre-push hooks#59
github-actions[bot] merged 1 commit into
masterfrom
worktree-ssh-keepalive-github

Conversation

@catomean

Copy link
Copy Markdown
Collaborator

Summary

  • git push opens the SSH connection to github.com before running the pre-push hook, then leaves it idle for the hook's entire duration.
  • Under heavy concurrent machine load (~80 sessions sharing this box), app-repo pre-push hooks (typecheck + full test suite) routinely took 5-10+ minutes — long enough that GitHub's idle-connection timeout closed the SSH session mid-hook.
  • Symptom: the hook suite prints "🎉 All pre-push checks passed! Safe to push." and then... nothing. The branch never lands on the remote, with only a stray "Connection to github.com closed by remote host." buried mid-log to explain it. Reproduced 4x in one session on orangecat before diagnosing via GIT_TRACE=1.
  • Fix: ServerAliveInterval 30 / ServerAliveCountMax 10 on 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

  • Diagnosed root cause via GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git push — confirmed the SSH session opens before the hook and drops during it
  • bash -n .ssh/config (repo's own CI check)
  • Watch a subsequent orangecat/fleetcrown push under load land cleanly on the first try

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y9rKLxddothnXEtY6KDziN

…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.
@github-actions
github-actions Bot merged commit ee45d89 into master Aug 29, 2026
1 check passed
@github-actions
github-actions Bot deleted the worktree-ssh-keepalive-github branch August 29, 2026 10:08
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.

1 participant