We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In the docs here: https://node-postgres.com/features/pooling#checkout-use-and-return
pool.on('error', (err, client) => { console.error('Unexpected error on idle client', err) process.exit(-1) }
The above sample code snippet did not seem to catch an error from an AWS RDS failover. I received this error when using sample code:
node:events:495 throw er; // Unhandled 'error' event ^ Error: Connection terminated unexpectedly at Connection.<anonymous> (/Users/malsup/Development/gitlab.workfront.tech/alloy/fusion-pg/node_modules/pg/lib/client.js:132:73)
However when I added an error event handler to the client in the response from the connect() call as below I was able to catch the error.
const { Pool } = require('pg') const start = async () => { const pool = new Pool({ user: 'postgres', password: 'postgres', host: 'localhost', port: 5432, }) // the pool will emit an error on behalf of any idle clients // it contains if a backend error or network partition happens pool.on('error', (err, client) => { console.error('Unexpected error on idle client', err) process.exit(-1) }) const client = await pool.connect() // Added snippet for client errors client.on('error', (err, client) => { console.error('Unexpected error on idle client', err) process.exit(-1) }) for (let i = 0; i < 500; i++) { const res = await client.query('SELECT 1') console.log(res.rows) await new Promise((resolve) => setTimeout(resolve, 500)) } client.release() } start()
Unexpected error on idle client Error: Connection terminated unexpectedly at Connection.<anonymous> (/Users/malsup/Development/gitlab.workfront.tech/alloy/fusion-pg/node_modules/pg/lib/client.js:132:73)
Is this a documentation issue or should the pool be "forwarding" this error event up from the client?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In the docs here: https://node-postgres.com/features/pooling#checkout-use-and-return
The above sample code snippet did not seem to catch an error from an AWS RDS failover. I received this error when using sample code:
However when I added an error event handler to the client in the response from the connect() call as below I was able to catch the error.
Is this a documentation issue or should the pool be "forwarding" this error event up from the client?
The text was updated successfully, but these errors were encountered: