Skip to content

Commit

Permalink
fix: pass error to pgpool release (typeorm#9209)
Browse files Browse the repository at this point in the history
This extends github PR typeorm#7792 to pass the error, if any, to the release
callback from `pg-pool`. This should be done to ensure the connection is
removed from the pool, as described in typeorm#5112.
  • Loading branch information
bryfox authored and nordinh committed Aug 29, 2022
1 parent 0ba024e commit 9ae05b7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/driver/postgres/PostgresQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ export class PostgresQueryRunner

const onErrorCallback = (err: Error) =>
this.releasePostgresConnection(err)
this.releaseCallback = () => {
this.releaseCallback = (err?: Error) => {
this.databaseConnection.removeListener(
"error",
onErrorCallback,
)
release()
release(err)
}
this.databaseConnection.on("error", onErrorCallback)

Expand All @@ -114,12 +114,12 @@ export class PostgresQueryRunner

const onErrorCallback = (err: Error) =>
this.releasePostgresConnection(err)
this.releaseCallback = () => {
this.releaseCallback = (err?: Error) => {
this.databaseConnection.removeListener(
"error",
onErrorCallback,
)
release()
release(err)
}
this.databaseConnection.on("error", onErrorCallback)

Expand Down

0 comments on commit 9ae05b7

Please sign in to comment.