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

Redis errors with ReplyError: ERR UNKOWN_CLIENT #212

Open
wmr-trevor opened this issue Feb 24, 2023 · 7 comments
Open

Redis errors with ReplyError: ERR UNKOWN_CLIENT #212

wmr-trevor opened this issue Feb 24, 2023 · 7 comments

Comments

@wmr-trevor
Copy link

There appears to be an issue with redis connections. They work fine for a time and then they seem to break.

It appears to me as if the error message that was used to determine if the client should be re-registered has changed. Instead of it only being UNKNOWN_CLIENT it is now ERR UNKOWN_CLIENT

else if e.message == "UNKNOWN_CLIENT"

The error received. This error happens exactly every 5 seconds.

ReplyError: ERR UNKNOWN_CLIENT
    at parseError (/app/node_modules/redis-parser/lib/parser.js:179:12)
    at parseType (/app/node_modules/redis-parser/lib/parser.js:302:14) {
  command: 'EVALSHA',
  args: [
    '8bd3e064b718321194a8df49c69e48fd0ffb4dcd',
    8,
    'b_node-print-rate-limit_settings',
    'b_node-print-rate-limit_job_weights',
    'b_node-print-rate-limit_job_expirations',
    'b_node-print-rate-limit_job_clients',
    'b_node-print-rate-limit_client_running',
    'b_node-print-rate-limit_client_num_queued',
    'b_node-print-rate-limit_client_last_registered',
    'b_node-print-rate-limit_client_last_seen',
    1677246715764,
    'fbe2isbe9mc'
  ],
  code: 'ERR'
}

In my setup I am passing in the redis connection details directly and using the redis datastore option.

const rateLimiter = new Bottleneck({
    maxConcurrent: 2,
    minTime: 100,

    // set the limiter id
    id: "node-print-rate-limit",

    // setup the redis store
    datastore: "redis",
    clientOptions: getDetails(),
    timeout: 30 * 1000,
});
@dobrynin
Copy link

dobrynin commented Mar 1, 2023

FYI I used patch-package to implement the above suggestion and it works for me, thanks!

Here is the diff that solved my problem:

diff --git a/node_modules/bottleneck/lib/RedisDatastore.js b/node_modules/bottleneck/lib/RedisDatastore.js
index dc5943e..c7b8fdb 100644
--- a/node_modules/bottleneck/lib/RedisDatastore.js
+++ b/node_modules/bottleneck/lib/RedisDatastore.js
@@ -181,7 +181,7 @@ RedisDatastore = class RedisDatastore {
               return _this3.runScript(name, args);
             });
           }
-        } else if (e.message === "UNKNOWN_CLIENT") {
+        } else if (e.message === "ERR UNKNOWN_CLIENT") {
           return _this3.runScript("register_client", [_this3.instance.queued()]).then(() => {
             return _this3.runScript(name, args);
           });

@justinadkins
Copy link

Did anyone discover why the prefix ERR was added here? I see a lua script here that has the UNKNOWN_CLIENT error. We just ran into this problem when we bumped to Redis 7.

@wmr-trevor
Copy link
Author

@justinadkins I haven't had a lot of extra time to get to the bottom of it but,

I came across some commits in the redis repo that seems to suggest where the prepended ERR comes from.
https://github.com/redis/redis/blame/e7f18432b8e9e1d1998d3a898006497e6c5e5a32/src/script_lua.c#L1583

The version 7 release notes also mention it as a Potentially Breaking Change for pull 10329.
https://github.com/redis/redis/releases/tag/7.0-rc2
redis/redis#10329

At this point I don't have a better option then to use patch-package to get around the issue.

@justinadkins
Copy link

Thank you for this lightning fast, detailed response @wmr-trevor 🙏. We are also going to use patch-package to resolve this for now.

@Sergiiivzhenko
Copy link

@wmr-trevor thanks for the detailed clarification, if anybody faces the same issue here is a working solution in my repo:
https://github.com/Sergiiivzhenko/bottleneck

published npm package:
https://www.npmjs.com/package/@sergiiivzhenko/bottleneck

@OscarMulder
Copy link

I was facing exactly this issue, thanks for the solutions provided! 👏

@maselious
Copy link

Similar compatibility issue including SETTINGS_KEY_NOT_FOUND

There is a package with both fixes

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

No branches or pull requests

6 participants