-
Notifications
You must be signed in to change notification settings - Fork 52
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
Listen for more socket failure events #163
Conversation
The `close` event is always called after an `error` event (https://nodejs.org/api/net.html#event-error_1), and `disconnect` is not an event emitted from a `net.Socket`. So we should only wait for a `close` event (which captures both `error` cases and non-`error` cases such as the server cleaning closing the connection with a FIN). This will avoid calling error callbacks twice (I believe this isn't technically a problem at the moment, but only calling `Server#error` once for a close should be more maintainable).
Hi @alevy. Running my test case from #162 with your patch in place, and restarting the memcached container triggers an application crash with:
As opposed to my previous attempt at fixing this, which reported several errors like the following, and then resumed when the server recovered:
It's possible my example code lacks appropriate error handling. I confess that to some extent I'm button mashing when it comes to Node. |
Additionally, I don't think the on close handler takes an error argument. We should probably separate the error and close handler. In the error handler just propagate the error and in the close handler deal with reconnection timeouts and so on. We just have to be careful since the error handling logic also touches reconnection variables (see line 63-67, are they even needed?). |
@saschat @alevy (as you two seem to be part of MemCachier org and can probably provide us with an update here): Is Services I'm currently working on are facing some issues with Listening I'm more than happy to provide a reproducible test case if needed. |
@olemstrom We semi-actively maintain it. This means we fix critical bugs and review PRs, but we currently don't have the capacity to actively work on it. As for this PR, it is broken in its current form, it actually introduces a subtle bug. As per my comment above, |
Obsolete since #170 |
Fixes #162.
I'm not sure if there's a better way to solve the problem, but listening for the
close
event seems to deal with the problem for me. If the host disappears suddenly,error
doesn't seem to be called. I addeddisconnect
just in case, but perhaps this is unnecessary.