Critical: File descriptor and goroutine leak in HandleConnection causing "too many open files" under load #56
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
HandleConnection leaks file descriptors and goroutines, causing "too many open files" errors under stress testing.
Root Cause
The function only waits for ONE goroutine to finish instead of both:
This leaves the second goroutine running and prevents proper cleanup of SSH channels and file descriptors.
Evidence
Debug logs show channels accumulating with buffered data stuck in half-closed state:
File descriptors reached 1023+ before the process was killed.
Fix
Wait for both goroutines:
Impact