From cbc5a7055fcb210a0c888f4654e7a00839b27c94 Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 23 Dec 2023 12:11:23 -0600 Subject: [PATCH] Fix: close conn on read failure in pipeline Suggested by @jameshartig in https://github.com/jackc/pgx/issues/1847 --- pgconn/pgconn.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pgconn/pgconn.go b/pgconn/pgconn.go index d5a67bea..32bc0f47 100644 --- a/pgconn/pgconn.go +++ b/pgconn/pgconn.go @@ -2117,7 +2117,8 @@ func (p *Pipeline) getResults() (results any, err error) { case *pgproto3.ParseComplete: peekedMsg, err := p.conn.peekMessage() if err != nil { - return nil, err + p.conn.asyncClose() + return nil, normalizeTimeoutError(p.ctx, err) } if _, ok := peekedMsg.(*pgproto3.ParameterDescription); ok { return p.getResultsPrepare()