From 2bc981c8102b7b289f5cb5ce1c5a68b32a3a3834 Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 08:23:06 +0000 Subject: [PATCH] fix: handle 'connection reset by peer' in postgres test utility Add 'connection reset by peer' to the list of errors that should trigger starting a new postgres container in the test utility. This fixes flaky tests that fail when PostgreSQL resets connections. Fixes: https://github.com/coder/internal/issues/695 Co-authored-by: ibetitsmike <203725896+ibetitsmike@users.noreply.github.com> --- coderd/database/dbtestutil/postgres.go | 1 + 1 file changed, 1 insertion(+) diff --git a/coderd/database/dbtestutil/postgres.go b/coderd/database/dbtestutil/postgres.go index e282da583a43b..decf740fb3754 100644 --- a/coderd/database/dbtestutil/postgres.go +++ b/coderd/database/dbtestutil/postgres.go @@ -71,6 +71,7 @@ func initDefaultConnection(t TBSubset) error { errSubstrings := []string{ "connection refused", // this happens on Linux when there's nothing listening on the port "No connection could be made", // like above but Windows + "connection reset by peer", // this happens when PostgreSQL resets the connection } errString := dbErr.Error() for _, errSubstring := range errSubstrings {