-
-
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
Handle bad message ordering - make it catchable. Fixes 3174 #3289
Conversation
Deploying node-postgres with Cloudflare Pages
|
packages/pg/lib/client.js
Outdated
_handleParseComplete(msg) { | ||
_handleParseComplete() { | ||
if (this.activeQuery == null) { | ||
this.emit('error', new Error('Received parseComplete when not in parsing state')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use _handleErrorEvent
, since the connection is in an unpredictable state afterwards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see how using _handleErrorEvent
might be a good idea here too, I think what @brianc communicated to me about this PR is that he thinks the issue is always related to an unexpected message arriving at a client which is in the idle state and so if that is the case it might not be required to do the full _handleErrorEvent
but I can see how maybe doing full _handleErrorEvent
is more robust.
Hey @brianc, here to add my two cents, first wanna say thanks for your attention to the issue report and thanks to @charmander as well for weighing in! I can see that this PR as is addresses I think it makes sense that whatever is decided to be done for Thanks! |
The biggest issue was when messages came in out of order sometimes the client would throw a null ref error in an uncatchable place in the code & crash the node process. As far as I know, this PR should totally fix that issue, changing the unhandled null ref error in the background into a catchable error emitted by the client (or pool if you use
pool.query
).Wrote a fake postgres backend to send messages out of order to test these weird edge cases outlined in #3174 where proxies or pg-bouncer or the like is getting messages mixed up. Can extend the test suite as needed and improve other edge cases. The native driver only emits a
notice
event when it receives an out of order message.