From 464c463be134360a42f42cc3d6713f5afe4c1efb Mon Sep 17 00:00:00 2001 From: Tanner Nelson Date: Mon, 23 Sep 2019 17:51:49 -0400 Subject: [PATCH] close conn if auth fails --- Sources/PostgresKit/PostgresConnectionSource.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/PostgresKit/PostgresConnectionSource.swift b/Sources/PostgresKit/PostgresConnectionSource.swift index 96b41037..f071ddf1 100644 --- a/Sources/PostgresKit/PostgresConnectionSource.swift +++ b/Sources/PostgresKit/PostgresConnectionSource.swift @@ -23,7 +23,10 @@ public struct PostgresConnectionSource: ConnectionPoolSource { username: self.configuration.username, database: self.configuration.database, password: self.configuration.password - ).map { conn } + ).flatMapError { error in + return conn.close() + .flatMapThrowing { throw error } + }.map { conn } } } }