Skip to content
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

Reconnect doesn't work without on('error') listener #2302

Closed
ivanpepelko opened this issue Oct 21, 2022 · 1 comment · Fixed by #2373
Closed

Reconnect doesn't work without on('error') listener #2302

ivanpepelko opened this issue Oct 21, 2022 · 1 comment · Fixed by #2373

Comments

@ivanpepelko
Copy link

Node processes containing redis clients would crash with SocketClosedUnexpectedlyError.
The reason is well known - timeout in redis.conf (in our case it's set to 1h, and our node processes would crash within same interval).

The problem is that without on('error') listener the error is seemingly considered 'uncaught' and crashes the process.
After adding the listener (it simply logs the error), the library would recreate/reconnect to the server and process would continue to live on.
Is this behavior by design? Or I missed something in docs?

This issue might also be related or the same as #2276, #2274 and #2273.

Environment:

  • Node.js Version: 16
  • Redis Server Version: 6.0
  • Node Redis Version: 3 & 4
  • Platform: linux (debian, arch)
@leibale
Copy link
Contributor

leibale commented Oct 21, 2022

this is how Node EventEmitter is designed (see https://nodejs.org/api/events.html#events_error_events), but because this question/issue comes up a lot, we should address it in the main README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants