question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RedisStore throws error when client object is passed

See original GitHub issue
const client = createClient();
const requestLimiter = rateLimit({
  store: new RedisStore({
    client
  }),
  windowMs: 1 * 60 * 1000 * 60, // 1h
  max: 100, // Limit IP to 100 requests per hour
  message: "Request limit exceeded! try again in a short while",
});

Throws the following error:

TypeError: options.client.multi(...).incr(...).pttl is not a function

Any solution please? I need to use the redis container in my docker network

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
stephentcommented, Jan 4, 2022

@jesseinvent I think this should be left open as an issue. This project needs updating to account for the version of client that might be passed in - right now it will use it as if it were a v3 client even if it is not.

1reaction
gamemaker1commented, Mar 28, 2022

Hi,

I recently helped out with the Typescript rewrite (PR #43), which also changes how the store interacts with Redis - v3.0.0 (~will be released soon!~ released!) accepts the sendCommand option instead of the client option.

sendCommand is a (sync/async) function that takes the raw command as an array of strings and returns the number or string response from redis. This makes the store compatible with all clients that have a public method to send raw commands to redis.

Please do take a look at the readme for examples of using the store with Redis and IORedis clients. The value to be passed for sendCommand option is also given here for most Redis clients.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redis NodeJs server error,client is closed - Stack Overflow
I am getting above error when user sends a message to the room or when socket.on("sendMessage") is called. Where am I going wrong?...
Read more >
Problem in connection to RedisStorage · Issue #808 - GitHub
My call to set the RedisStore was generating an unauthorized error, even though I was passing in authorized clients. It turned out that...
Read more >
Redis client connects to the redis remote server but can't read ...
I've to manage two servers 'Node_server' and a redis server 'Redis_server' by making the connection possible from a node/express application ...
Read more >
Session Management in Nodejs Using Redis as Session Store
Create express-session and pass it to connect-redis object as parameter. This will initialize it. Then in session middleware, pass the Redis ...
Read more >
Session handling in Express Using Redis | Code for geek
Create express-session and pass it to connect-redis object as parameter. This will initialize it. Then in session middleware, pass the Redis store information ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found