redis / redis/node-redis

Unable to make client.quit() async

Open
#1,544 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Issue

Unable to make client.quit() async

I would like to make client.quit into quitAsync (just like client.get can).

I have tried the following two methods. Neither of them wait for the promise to resolve or reject!

let client = redis.createClient(options);

// Method 1
client._quit = promisify(client.quit).bind(client);

// Method 2
        client._quit = () => {
            return new Promise((resolve, reject) => {
                client.quit((err, d) => {
                    if (!err) {
                       console.log("1");
                        return resolve(d)
                    } else {
                        return reject(err)
                    }
                });
                // if (!result) {
                //     return reject(new Error("client/connection does not exist"))
                // }
            });
        };

// some where else 
await conn._quit(); 
console.log("2");

Using method-2 Expected

"1" gets printed before "2"

Using method-2 Actual

"2" gets printed on the console before "1" ! how and why?

Environment
  • Node.js Version: 14.2.0
  • Redis Version: 5.0.6
  • Platform: Win 10

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 at the client.quit entry point and compare it with the existing client.get asynchronous behavior. Reproduce the provided client.createClient and await conn._quit example, then verify that completion is reported only after quit resolves or rejects and that the expected ordering is restored.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.