koajs / ratelimit

Rate limiter middleware
MIT License
485 stars 57 forks source link

async-ratelimiter does not support `redis` library #60

Closed scragg0x closed 3 years ago

scragg0x commented 3 years ago

The old ratelimiter library has an ioredis check:

var isIoRedis = Array.isArray(res[0]);
var count = parseInt(isIoRedis ? res[1][1] : res[1]);
var oldest = parseInt(isIoRedis ? res[3][1] : res[3]);
var oldestInRange = parseInt(isIoRedis ? res[4][1] : res[4]);

but async-ratelimiter does not.

This will cause erroneous 429s to occur with the latest version of koa-ratelimit for people using the regular redis library. Please list this as a breaking change.

https://github.com/microlinkhq/async-ratelimiter/issues/22

I'm not interested into support node-redis since ioredis have all the features necessaries and the project is well maintained 🙂

tony3918 commented 3 years ago

Not sure if this is the same issue but when I pass RedisClient from node-redis into koa-ratelimit's db, an error occurs Cannot read property '1' of undefined

Is this library only to be used with ioredis?

miladmeidanshahi commented 3 years ago

same issue doesn't work with node-redis.

3imed-jaberi commented 3 years ago

I open a PR in async-ratelimiter here. Some time and everything will be fine.

3imed-jaberi commented 3 years ago

Hi guys, I fixed the missing behave in async-ratelimiter and now everything work just I wait @niftylettuce to merge my PR #62 and everything done 🎉.

niftylettuce commented 3 years ago

v5.0.1 released to npm

https://github.com/koajs/ratelimit/releases/tag/v5.0.1