Skip to content

Commit ee45d89

Browse files
authored
fix(ssh): keep the github.com connection alive through slow pre-push hooks (#59)
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. Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com>
1 parent 87d3203 commit ee45d89

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

.ssh/config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@ Host github.com
44
User git
55
IdentityFile ~/.ssh/github_ed25519
66
IdentitiesOnly yes
7+
# git push opens this connection BEFORE running the pre-push hook, then
8+
# leaves it fully idle for the hook's entire duration. Found 2026-08-29:
9+
# under heavy concurrent machine load (~80 sessions), hooks routinely ran
10+
# long enough that GitHub's idle-connection timeout killed the SSH session
11+
# while the hook was still running — the push then silently failed to
12+
# transfer after printing "Safe to push," with only a stray "Connection to
13+
# github.com closed by remote host." in the log to explain it. Active
14+
# keepalives during that idle window prevent the drop.
15+
ServerAliveInterval 30
16+
ServerAliveCountMax 10

0 commit comments

Comments
 (0)