redis / redis/node-redis

Got an unexpected reply from Redis on unsubscribing from multiple channels at once

Open
#2,052 6 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
TypeScript
Stars
17.6k
Forks
2k
Avg merge
2d 3h
Merged PRs (30d)
40

Description

I have a very simple script:

const sub = createClient();
function handler(...args) {
    console.log(...args);
}
await sub.subscribe(['some1', 'some2'], handler);
setTimeout(() => {
    sub.unsubscribe(['some1', 'some2'], handler);
}, 5000);

And after 5sec it crashes with the following stacktrace:

/Users/mif/Documents/GitHub/uify/apps/frontend/src/node_modules/@node-redis/client/dist/lib/client/commands-queue.js:285
        throw new Error('Got an unexpected reply from Redis');
              ^
Error: Got an unexpected reply from Redis
    at RedisCommandsQueue._RedisCommandsQueue_shiftWaitingForReply (/Users/mif/Documents/GitHub/uify/apps/frontend/src/node_modules/@node-redis/client/dist/lib/client/commands-queue.js:285:15)
    at JavascriptRedisParser.returnReply (/Users/mif/Documents/GitHub/uify/apps/frontend/src/node_modules/@node-redis/client/dist/lib/client/commands-queue.js:58:124)
    at JavascriptRedisParser.execute (/Users/mif/Documents/GitHub/uify/apps/frontend/src/node_modules/redis-parser/lib/parser.js:544:14)
    at RedisCommandsQueue.parseResponse (/Users/mif/Documents/GitHub/uify/apps/frontend/src/node_modules/@node-redis/client/dist/lib/client/commands-queue.js:194:71)
    at RedisSocket.<anonymous> (/Users/mif/Documents/GitHub/uify/apps/frontend/src/node_modules/@node-redis/client/dist/lib/client/index.js:336:83)
    at RedisSocket.emit (node:events:527:28)
    at RedisSocket.emit (node:domain:475:12)
    at Socket.<anonymous> (/Users/mif/Documents/GitHub/uify/apps/frontend/src/node_modules/@node-redis/client/dist/lib/client/socket.js:189:44)
    at Socket.emit (node:events:527:28)
    at Socket.emit (node:domain:475:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)

Environment:

  • Node.js Version: 17.6.0
  • Redis Server Version: Redis server v=6.2.6 sha=00000000:0 malloc=libc bits=64 build=f91e6fead97295d3
  • Node Redis Version: 4.0.4
  • Platform: Mac OS 12.2.1 (21D62)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the subscribe and unsubscribe calls in the report and reproduce them against Redis 6.2.6 using Node Redis 4.0.4. Inspect the commands-queue.js stack-trace path to determine why the multiple-channel unsubscribe reply is unexpected; done means the script no longer crashes and handles the Redis replies correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, redis, typescript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.