question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

client.query doesn't call back if connection has been lost

See original GitHub issue

Hi - 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:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pipmurphycommented, Jun 12, 2017

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.

0reactions
charmandercommented, Jul 26, 2018

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found