diff --git a/SPONSORS.md b/SPONSORS.md index 71c5210bc..3bebb01eb 100644 --- a/SPONSORS.md +++ b/SPONSORS.md @@ -13,6 +13,9 @@ node-postgres is made possible by the helpful contributors from the community as - [simpleanalytics](https://simpleanalytics.com/) - [n8n.io](https://n8n.io/) - [mpirik](https://github.com/mpirik) +- [@BLUE-DEVIL1134](https://github.com/BLUE-DEVIL1134) +- [bubble.io](https://bubble.io/) +- GitHub[https://github.com/github] # Supporters diff --git a/packages/pg-pool/index.js b/packages/pg-pool/index.js index 20dbe734c..00f55b4da 100644 --- a/packages/pg-pool/index.js +++ b/packages/pg-pool/index.js @@ -417,11 +417,11 @@ class Pool extends EventEmitter { client.release(err) if (err) { return cb(err) - } else { - return cb(undefined, res) } + return cb(undefined, res) }) } catch (err) { + client.release(err) return cb(err) } }) diff --git a/packages/pg-pool/test/error-handling.js b/packages/pg-pool/test/error-handling.js index f514bd79f..7b1570859 100644 --- a/packages/pg-pool/test/error-handling.js +++ b/packages/pg-pool/test/error-handling.js @@ -38,14 +38,15 @@ describe('pool error handling', function () { }) it('Catches errors in client.query', async function () { - await expect((new Pool()).query(null)).to.throwError() - await expect(async () => { - try { - await (new Pool()).query(null) - } catch (e) { - console.log(e) - } - }).not.to.throwError() + let caught = false + const pool = new Pool() + try { + await pool.query(null) + } catch (e) { + caught = true + } + pool.end() + expect(caught).to.be(true) }) describe('calling release more than once', () => {