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 } } } }