client.query doesn't call back if connection has been lost
See original GitHub issueHi - we’ve come across a scenario where client.query doesn’t invoke the callback as we would expect:
If the connection is initially successful, but later disconnects (for example due to network issues), subsequent calls to client.query just seem to vanish into the ether. We had expected them to invoke the callback with an error object. Is this intended behaviour? If so, is there a workaround?
Having dug into lib/client.js line 307, I wonder if this is related:
Client.prototype._pulseQueryQueue = function() {
if(this.readyForQuery===true) {
...
If the connection isn’t ready for query, nothing seems to happen!
We’re using pg@6.2.2 with node 6.9.1, and AWS Aurora Postgres.
Thanks in advance for any guidance you can give.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Node - Database query callback not firing - Stack Overflow
1 Answer 1 ... pg.connect(connectionString, (err, client, done) => { // Handle connection errors if(err) { done(); console.log(err); return res.
Read more >Handling operation errors - Apollo GraphQL Docs
Apollo Client helps you handle these errors according to their type, enabling you to show appropriate information to the user when an error...
Read more >Common Errors When Using MySQL - O'Reilly
The most common reason for the MySQL server has gone away error is that the server timed out and closed the connection. By...
Read more >Troubleshooting connection issues | Socket.IO
That being said, the Socket.IO client will always try to reconnect, unless specifically told otherwise. Let's review how you can ...
Read more >12 Response Templates for Tricky Customer Service Emails
For some customers, a lack of phone support is a deal breaker, ... A customer is asking for a product feature you know...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @brianc, that would be perfect - I do think every callback like this needs to be invoked, if only with an error - that’s certainly been my expectation in using this package (which is fantastic, btw) and the callback-with-error pattern generally.
@ccakes The queries are queued with the assumption that you’ll call
connect()
at some point in the future. I don’t think the query queue on clients is a good part of pg, but that, at least, is intended behaviour.