env:
nodejs : 10.12.0
redis: 5.0.1 sentinels cluster
code:
import { CallbackFunction, RedisOptions } from "ioredis"
import * as IORedis from "ioredis"
const clientMap: { [channel: string]: IORedis.Redis } = {}
const getClient = (channel: string) => {
if (!(channel in clientMap))
clientMap[channel] = new IORedis(connOptions)
return clientMap[channel]
}
brpop: (key: string[]) => {
return getClient("list").brpop(...key)
}
but I check the ts package index.d.ts:
brpop(...keys: KeyType[]): any;
i'm sure the params is correct.
when I call the brpop function, it's error:
(node:12812) UnhandledPromiseRejectionWarning: ReplyError: ERR wrong number of arguments for 'brpop' command
at parseError (/Users/zhoujie/Projects/notify_server/node_modules/ioredis/node_modules/redis-parser/lib/parser.js:179:12)
at parseType (/Users/zhoujie/Projects/notify_server/node_modules/ioredis/node_modules/redis-parser/lib/parser.js:302:14)
(node:12812) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
env:
nodejs : 10.12.0
redis: 5.0.1 sentinels clustercode:
import { CallbackFunction, RedisOptions } from "ioredis"
import * as IORedis from "ioredis"
const clientMap: { [channel: string]: IORedis.Redis } = {}const getClient = (channel: string) => {
if (!(channel in clientMap))
clientMap[channel] = new IORedis(connOptions)
return clientMap[channel]
}brpop: (key: string[]) => {
return getClient("list").brpop(...key)
}but I check the ts package index.d.ts:
brpop(...keys: KeyType[]): any;i'm sure the params is correct.
when I call the brpop function, it's error:
(node:12812) UnhandledPromiseRejectionWarning: ReplyError: ERR wrong number of arguments for 'brpop' command
at parseError (/Users/zhoujie/Projects/notify_server/node_modules/ioredis/node_modules/redis-parser/lib/parser.js:179:12)
at parseType (/Users/zhoujie/Projects/notify_server/node_modules/ioredis/node_modules/redis-parser/lib/parser.js:302:14)
(node:12812) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
I believe brpop command minimum of 2 arguments:
Plz refer documentation as below:
https://redis.io/commands/blpop
Try passing 0 if you want infinite block r else pass some timeout in ms, if you want to block till that time.

wait updating...
wait updating...
By Passing a 2nd argument as 0/some timeout didn't work out? @No1Jie
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs, but feel free to re-open a closed issue if needed.
I just ran into this problem. These are the type definitions for blpop and brpop.
brpop(...keys: KeyType[]): any;
blpop(...keys: KeyType[]): any;
These methods require a timeout value. What's not obvious, is that you need to supply this as a string. Example:
const result = await brpop("mykey", "30");
Where 30 is the timeout in seconds.
Most helpful comment
I just ran into this problem. These are the type definitions for
blpopandbrpop.These methods require a timeout value. What's not obvious, is that you need to supply this as a string. Example:
Where
30is the timeout in seconds.