fix: 'uc image push' closed network connection error if takes >10s (fixes #141)

This commit is contained in:
Pasha Sviderski
2025-10-13 20:19:46 +10:00
parent 75b932b66e
commit 6ba98e4576
+3 -2
View File
@@ -81,10 +81,11 @@ func (p *Proxy) handleConnection(ctx context.Context, localConn net.Conn) {
defer p.activeConns.Done()
defer localConn.Close()
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
// Use a separate context with timeout for dialing the remote address.
dialCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
remoteConn, err := p.DialContext(ctx, "tcp", p.RemoteAddr)
remoteConn, err := p.DialContext(dialCtx, "tcp", p.RemoteAddr)
if err != nil {
if p.OnError != nil {
p.OnError(fmt.Errorf("connect remote address '%s': %w", p.RemoteAddr, err))