Unable to make client.quit() async

オープン
#1,544 コメント 5 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
node.js
領域
api

調査の方向性

client.quit のエントリーポイントから開始し、既存の client.get の非同期動作と比較してください。提示された client.createClient と await conn._quit の例を再現し、quit が resolve または reject した後にのみ完了が報告されること、そして期待される順序が復元されることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
TypeScript
スター
17.6k
フォーク
2k
平均マージ
1日 22時間
マージ済み PR(30日)
62

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

redis/node-redis のほかの issue

redis/node-redis の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。