From 2cdd00a798430625f403d5ea38d25a75f3333267 Mon Sep 17 00:00:00 2001 From: Tanner Date: Mon, 23 Sep 2019 17:54:36 -0400 Subject: [PATCH] close conn if auth fails (#144) --- 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 } } } }