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

Latest version of Redis won't automatically reconnect without error handling #8705

Closed
4 tasks done
Vortec4800 opened this issue Aug 1, 2023 · 6 comments · Fixed by #8706
Closed
4 tasks done

Latest version of Redis won't automatically reconnect without error handling #8705

Vortec4800 opened this issue Aug 1, 2023 · 6 comments · Fixed by #8706
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version

Comments

@Vortec4800
Copy link
Contributor

New Issue Checklist

Issue Description

I'm using a Redis Server hosted by Digital Ocean, and it disconnects every so often for whatever reason. With Redis 3.x this wasn't a big deal, the client would automatically reconnect. With Redis 4.x, you get an error in the console that complains about the lack of error handling.

It appears that added (even empty) event handlers during client creation is enough to bring back the behavior of Redis 3. I will create a PR with this change for reference.

Environment

Server

  • Parse Server version: 6.2.1
  • Operating system: Ubuntu 20 LTS
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Digital Ocean

Logs

Before PR change:

node:events:492
      throw er; // Unhandled 'error' event
      ^

SocketClosedUnexpectedlyError: Socket closed unexpectedly
    at TLSSocket.<anonymous> (/var/parse/parse-server/node_modules/@node-redis/client/dist/lib/client/socket.js:182:118)
    at Object.onceWrapper (node:events:629:26)
    at TLSSocket.emit (node:events:526:35)
    at node:net:323:12
    at TCP.done (node:_tls_wrap:588:7)
Emitted 'error' event on Commander instance at:
    at RedisSocket.<anonymous> (/var/parse/parse-server/node_modules/@node-redis/client/dist/lib/client/index.js:339:14)
    at RedisSocket.emit (node:events:514:28)
    at RedisSocket._RedisSocket_onSocketError (/var/parse/parse-server/node_modules/@node-redis/client/dist/lib/client/socket.js:205:10)
    at TLSSocket.<anonymous> (/var/parse/parse-server/node_modules/@node-redis/client/dist/lib/client/socket.js:182:107)
    at Object.onceWrapper (node:events:629:26)
    [... lines matching original stack trace ...]
    at TCP.done (node:_tls_wrap:588:7)

Node.js v18.17.0

(Redis client does not reconnect after this message appears in the console, later errors show client is closed when the cache attempts to be used)

PR change adds the following handlers:

this.client.on('error', err => console.log('Parse Redis client error', err));
this.client.on('connect', () => console.log('Parse Redis client is connected'));
this.client.on('reconnecting', () => console.log('Parse Redis client is reconnecting'));
this.client.on('ready', () => console.log('Parse Redis client is ready'));

After PR change:

On initial launch, showing client creation and connection:

Parse Redis client is connected
Parse Redis client is connected
Parse Redis client is ready
Parse Redis client is ready
Parse Redis client is connected
Parse Redis client is ready

When a disconnect happens:

Parse Redis client error SocketClosedUnexpectedlyError: Socket closed unexpectedly
    at TLSSocket.<anonymous> (/var/parse/parse-server/node_modules/@node-redis/client/dist/lib/client/socket.js:182:118)
    at Object.onceWrapper (node:events:629:26)
    at TLSSocket.emit (node:events:526:35)
    at node:net:323:12
    at TCP.done (node:_tls_wrap:588:7)
Parse Redis client is reconnecting
Parse Redis client is connected
Parse Redis client is ready

Future disconnects repeat the same message, showing the connection gets closed but then reopens and everything continues to work normally.

@parse-github-assistant
Copy link

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 6.3.0-alpha.8

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Aug 30, 2023
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 6.4.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Sep 16, 2023
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 6.4.0-alpha.1

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 6.4.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Nov 16, 2023
@ChrisGrant
Copy link

ChrisGrant commented Jan 25, 2024

@Vortec4800 Did this change definitely fix the issue for you? I've just tried upgrading to Parse Server 6.4.0 and it still happens for me.

Screenshot 2024-01-25 at 06 53 29

Here's my dependencies:

"parse": "4.3.1",
"parse-dashboard": "5.3.0",
"parse-server": "6.4.0",

This only happens when it is running on Heroku. Seems to work fine when I run I am running the sever locally (macOS).

It seems somewhat strange that it worked fine on parse 5.5.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants