Skip to content

Commit

Permalink
Await destroyRawConnection in Postgres cancelQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmacko47 committed Mar 3, 2021
1 parent 0787821 commit 51b5191
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions lib/dialects/postgres/index.js
Expand Up @@ -237,18 +237,12 @@ class Client_PG extends Client {
}

async cancelQuery(connectionToKill) {
// Error out if we can't acquire connection in time.
// Purposely not putting timeout on `pg_cancel_backend` execution because erroring
// early there would release the `connectionToKill` back to the pool with
// a `KILL QUERY` command yet to finish.
const conn = await this.acquireRawConnection();

try {
return await this._wrappedCancelQueryCall(conn, connectionToKill);
} finally {
// NOT returning this promise because we want to release the connection
// in a non-blocking fashion
this.destroyRawConnection(conn);
await this.destroyRawConnection(conn);
}
}
_wrappedCancelQueryCall(conn, connectionToKill) {
Expand Down

0 comments on commit 51b5191

Please sign in to comment.