-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Don't emit error events parsed out of data stream #843
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
Conversation
The connection parses errors out and emits them just as any other message so they can be handled higher up. Either by the client if a query is executing or emitted into the client's application. Not emitting errors basically removes any indication that anything has gone wrong including a query failure, bad query syntax, a disconnection...anything. Swallowing errors is a total no-go, sorry. What is the actual problem you're running into? |
@brianc The problem I'm running into is #746. I also wrote up a short analysis of what's going wrong in there. Swallowing errors is definitely not the intention of the patch, although I do realize now that that is what's happening. However, the duplicate error and the inability to handle that error is definitely a problem. I'd be happy to work on a proper solution once I understand all aspects of the error handling. |
Ah I see now - much more context. Yeah so eating the error is probably not the right approach here. In the case of a bad password some installs of postgres will disconnect the socket after a bad password attempt. This causes the socket to emit an error, which is passed up via the connection -> client like you were describing. Problem is, which you also outlined, is that the client already received an error message from postgres about the bad password. The right way to handle this is probably something like this... if the client is trying to connect and the stream emits an error or the client receives an error message and the client is pooled...then suppress any further error messages on the client within the pool, and dispose of the client. I haven't been able to fix this because I don't have access to an instance of postgres that has the double-error problem, but if you wanna take a crack at fixing it there in the pool I'd 100% ❤️ to merge the PR! |
Awesome. I'll try to find a proper solution. I'm really wondering about this double-error thing though. I was recently looking into a very similar issue at voxpelli/node-pg-pubsub#6 and I'm assuming @voxpelli never experienced this either. I think I saw mentioning that this might be a Windows issue, which seems reasonable, given that I'm on Windows. |
I hope I'm not causing too much trouble with the pushes, but I can't run the tests on Windows locally so far, so I'm letting travis handle that. |
No trouble at all. I only get travis email on master pass/fail or PRs I am On Mon, Aug 24, 2015 at 10:09 AM, Oliver Salzburg notifications@github.com
|
@brianc I'm a bit stuck right now. The test failure is telling me that |
Okay, so it's a |
Okay, got it, I was missing the mocked @brianc You mentioned disposing the client. From what I can tell, that should already be happening, because all the connection-related error handling is already in place. With the current approach, only the one specific case where two (or multiple) errors are generated, before a connection has been established, is handled. Is that enough? |
@brianc If you could provide some feedback on this, I'd really appreciate it :) |
@oliversalzburg sorry for taking a while to get to this - I think this actually looks really good! Also - that's a cool trick for |
Don't emit error events parsed out of data stream
Awesome! 👍 :) |
Messages with the name
error
will also cause theerror
event to be raised on the stream. Thus, emitting the event here again will only cause problems.Fixed #746