Skip to content

Fix error handling test #2789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions SPONSORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions packages/pg-pool/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
Expand Down
17 changes: 9 additions & 8 deletions packages/pg-pool/test/error-handling.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down