redis / redis/node-redis

client.flush() disallows the 'end' event to be emitted

Open
#1,565 1 comment 0 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

Using the latest redis 3.0.2.

Iif someone calls client.flush() no further events are emitted by the Redis client. At least the 'end' event should be emitted in order to notify users that the socket has been closed.
The problem lies in redis/lib/extendedApi.js:

RedisClient.prototype.end = function (flush) {
    ...
    this.stream.removeAllListeners();
    this.stream.on('error', noop);
    this.connected = false;
    this.ready = false;
    this.closing = true;
    return this.stream.destroySoon();
};

Not all socket listeners should be removed. Either the 'close' listener attached in line 225 of redis/index.js should be preserved/restored or an ad-hoc listener emitting 'end' should be added after the

this.stream.removeAllListeners();

line above.

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 in redis/lib/extendedApi.js at RedisClient.prototype.end and compare it with the 'close' listener attached in redis/index.js around line 225. Trace the client.flush() path and verify that closing the stream still emits the client’s 'end' event without suppressing required error handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, redis
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.