-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fix for issue #964: connection error prevents pool from ending connection #964 #974
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
So, adding a function that swallows all errors is not the correct fix; errors need to be handled. The references issue needs to be fixed, yes, but simply swallowing all errors is not the correct way. |
@dougwilson, I agree with you, but is |
Is there a guarantee that all errors will be followed by an end event? Also, how does this fix #964 ? The |
Nevermind, I read the test incorrectly. |
Is there a guarantee you can point to me in the code that |
Basically, it sounds like the bug is in the interaction between |
If it helps, I looked into this a while ago, and what I found needed to be fixed was https://github.com/felixge/node-mysql/blob/048f2c1040b760f0c15fe800689b590343df0f1c/lib/protocol/Protocol.js#L366-L368 was not correctly getting invoked, leaving the |
And I believe it was because the error delegation calculation was wrong for the specific case. |
Also, the |
P.S., I'm not saying your solution here doesn't solve the problem or not, but the change just smells wrong to me, so I'm very iffy in accepting it without knowing more. Ideally there are not empty event listeners, but if there is absolutely no other way to fix it without breaking backwards-compatibility, I'm fine, but essentially I would accept changing it to an empty event listener as a last resort if there is no other possible solution. |
I totally agree with you @dougwilson, and thank you for the clarifications. |
No problem :) I look forward to this being fixed, and it's really awesome that you included a test! I don't mean to sound harsh or anything :) |
Sure, thanks! :) |
When an error event bubbled up to
PoolConnection
,pool._removeFromPool
was being called, so the connection was being removed from the array but not destroyed. Then, whenpool.end
was called, the connection wasn't being ended, since we didn't have any reference to it anymore.This pull request adds a test to cover that issue and fixes it by removing the call to
pool._removeFromPool
on connection error, since it's not necessary.