-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Enabling legacyMode and pingInterval together leads to reproducible crash #2383
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
Comments
Here's a diff --git a/node_modules/@redis/client/dist/lib/client/index.js b/node_modules/@redis/client/dist/lib/client/index.js
index 908d92e..7dfd2cd 100644
--- a/node_modules/@redis/client/dist/lib/client/index.js
+++ b/node_modules/@redis/client/dist/lib/client/index.js
@@ -430,7 +430,11 @@ _RedisClient_options = new WeakMap(), _RedisClient_socket = new WeakMap(), _Redi
__classPrivateFieldSet(this, _RedisClient_pingTimer, setTimeout(() => {
if (!__classPrivateFieldGet(this, _RedisClient_socket, "f").isReady)
return;
- this.ping()
+ (
+ __classPrivateFieldGet(this, _RedisClient_options, "f")?.legacyMode
+ ? this.v4.ping
+ : this.ping
+ ).call(this)
.then(reply => this.emit('ping-interval', reply))
.catch(err => this.emit('error', err))
.finally(() => __classPrivateFieldGet(this, _RedisClient_instances, "m", _RedisClient_setPingTimer).call(this)); (Initially I tried |
@benjie I manually applied your patch to my local install and confirmed it fixes the issue. Thanks for the quick response! |
No worries, I just happened to be hit by the same issue as you just 12 hours later, by pure coincidence! |
I've opened a PR but because I don't have Docker on this machine I cannot run your test suite; feel free to take over that PR. |
Creating a redis client with
legacyMode: true
AND a non-zeropingInterval
leads to a 100% reproducible crash.Demonstration:
Output:
https://github.com/redis/node-redis/blob/master/packages/client/lib/client/index.ts#L365-L368 seems to assume
.ping()
always returns a promise.Environment:
The text was updated successfully, but these errors were encountered: