-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
pg doesn't invoke callback if server accepts the connection and immediately disconnects #534
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
Hey! thanks for the awesome example code. I'll try to get this fixed for the v3.0 release (this weekend). Cheers. |
No problem, thanks for responding so quickly. Let me know if I can be of any assistance. |
I might be experiencing this or a similar problem with [email protected] and pg@master (2.11.0+, 2716f95): |
2.4.0 is also affected |
The native module handles this better (although with obscure error):
|
@brianc the Connection object only sends 'error' or 'end' events. When the other end closes the connection, an 'end' is received by the "stream" object, not an 'error'. How to turn that into an 'error' based on expectance ? |
Could we say, for example, that getting 'end' before getting 'readyForQuery' has to be considered an error ? |
This seems to fix this case for me:
|
Basically, if "callback" is still set, it means it wasn't called on "readyForQuery" |
The patch is meant for 2.11.1 |
Test adapted by that provided by Jess Sheneberger in brianc#534
This time, I hope, travis will confirm that the fix works with node-0.10 but not with node-0.8
Should fix missing connect callback call with node-0.8 (brianc#534)
@jess-sheneberger could you test #546 ? |
Should fix missing connect callback call with node-0.8 (brianc#534)
I’ll try to take a look later today. Thanks for the fix! |
Works for me. Thanks again for fixing this! |
Sweet - I'll get to these ASAP, test 'em and merge them in. |
@brianc Any idea when you'll be able to merge the fix to this one? |
I've got a short repro of the issue: https://gist.github.com/jess-sheneberger/9532352
When I run the code in the gist, the output I get is:
...and then the program ends, meaning client.connect's callback was never invoked. I expected to see another line after "server closed", something like "Error on connect: " or "client connected".
Some context: I'm using postgres behind a HAProxy. Sometimes HAProxy accepts a connection, fails to connect to postgres and then disconnects. This causes my initialization scripts to fail consistently.
I can reproduce this on both my Ubuntu 12.04 VM and on OSX Mavericks.
The text was updated successfully, but these errors were encountered: