-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
client.query doesn't call back if connection has been lost #1322
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
Comments
Ah! Sorry for the problem! I recently (like 5 days ago) fixed an issue with
disconnects not raising errors properly. Can you upgrade to 6.2.4 and give
it a try?
…On Mon, Jun 12, 2017 at 10:31 AM Phil Murphy ***@***.***> wrote:
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 ***@***.*** with node 6.9.1, and AWS Aurora Postgres.
Thanks in advance for any guidance you can give.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1322>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADDoUe_l2WG7oQjL3oTzdUOhGT7gfzZks5sDVm7gaJpZM4N3SQ->
.
|
Thanks for coming back to me so quickly @brianc :) We've upgraded to [email protected] but sadly the behaviour seems to be the same :/ Here's an example test script I've put together to show the behaviour:
When I run this, it correctly outputs the error for 'connected', but it never displays 'queried'... |
Ahh okay - I can make the query result in an error on a client that has had its connection terminated by either a graceful or unexpected connection interruption - I see what you're saying about queries just disappearing into a client that isn't connected. Would that help? |
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. |
I'm having the problem as well in unit tests (using real database connection with test database(s)). When database connection fails, the tests continue timing out since pgClient.query() doesn't give the callback. |
Seems like Simple example, seems to be identical with most pg & pg.native. I didn't open a new issue because I'm assuming the underlying cause is the same. const process = require('process');
const { Client } = require('pg');
const db = new Client({
connectionString: 'postgres://test@localhost:5433/test'
});
db.on('error', err => console.log('ERR|> ', err));
// db.connect();
db.query('select now() as now')
.then(res => console.log('RES|> ', res.rows))
.then(() => process.exit(0))
.catch(err => console.log('QERR|>', err)); |
This comment has been minimized.
This comment has been minimized.
@ccakes The queries are queued with the assumption that you’ll call |
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:
If the connection isn't ready for query, nothing seems to happen!
We're using [email protected] with node 6.9.1, and AWS Aurora Postgres.
Thanks in advance for any guidance you can give.
The text was updated successfully, but these errors were encountered: