From 3f1023d13c03a01e0adc50f94b5d693232ca9aba Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Fri, 28 Jun 2024 09:49:20 -0400 Subject: [PATCH] Shorten timeout for unhandled error to 1 second Signed-off-by: Jordan Liggitt --- connection.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/connection.go b/connection.go index 1b534e8..1394d0a 100644 --- a/connection.go +++ b/connection.go @@ -741,7 +741,15 @@ func (s *Connection) shutdown(closeTimeout time.Duration) { } if err != nil { - duration := 10 * time.Minute + // default to 1 second + duration := time.Second + // if a closeTimeout was given, use that, clipped to 1s-10m + if closeTimeout > time.Second { + duration = closeTimeout + } + if duration > 10*time.Minute { + duration = 10 * time.Minute + } timer := time.NewTimer(duration) defer timer.Stop() select {