-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
pg.connect returns both err and client as nulls when PostgreSQL is down #418
Comments
Yeah that' sounds like a bug. Do you have steps to reproduce this? |
I think this is what I'm seeing here too: CartoDB/CartoDB-SQL-API#135 Adding debugging logs I get:
Evidently the stream error did not trigger connection removal from the pool, which returned the same "bad" connection again on next .acquire call. I also reported this in a comment to #534 but now I'm not sure anymore if this is the real reason for my problem (or I'm having both). Tested versions (all affected): 2.4.0, 2.6.2, 2.11.0+ (2716f95) |
Sorry, I'm obviously getting a client object from aquire, so not the same as this bug either :/ |
Installing a listener for "end" event on the client from lib/pool.js to destroy the client fixes my case. |
This is the code snippet triggering "end" event for a client but no "error" event:
Should that be an error instead ? |
forget it, I don't confirm that handling "end" fixes my case, must have been a lucky run |
Sorry for the confusion, the patch actually works, only when I re-tested it I added a syntax error which broke it. The working patch is here:
|
I wrote an application using the connection pool, and it had gone well until PostgreSQL went down (actually, a network error), and, as far as i can tell, pg.connect returned a null client AND a null error, hence breaking my code (I expected err to be non-null in a case like this).
It has been easy to patch up my code, but I suppose this is not the intended pg.connect behavior.
The text was updated successfully, but these errors were encountered: