Skip to content

fix(client): bring disableClientInfo option back #2959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025

Conversation

nkaradzhov
Copy link
Collaborator

@nkaradzhov nkaradzhov commented May 9, 2025

It disappeared in v5

fixes #2958


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

@nkaradzhov
Copy link
Collaborator Author

@bobymicroby @htemelski Im not sure if this needs to be done for Sentinel, Cluster as well?

@bobymicroby
Copy link
Member

Im not sure if this needs to be done for Sentinel, Cluster as well?

I think Sentinel and Cluster reuse the handshake logic defined in lib/client/index.ts, so you don't have to do something extra.

@nkaradzhov nkaradzhov force-pushed the bring-disableclientinfo-back branch from 4d516fa to ba1b104 Compare May 15, 2025 08:38
@nkaradzhov
Copy link
Collaborator Author

@bobymicroby it looks like we are using #handshake in one more place - in the reset function
Im not sure if we need to add the client setinfo commands there as well?

@bobymicroby
Copy link
Member

@bobymicroby it looks like we are using #handshake in one more place - in the reset function Im not sure if we need to add the client setinfo commands there as well?

Why don't we refactor the handshake to separate concerns better? We could nest the current command creation logic in a private #createHandshakeCommands method, then have #handshake actually queue these commands and return promises for their completion. Then we can reuse it in reset and the socket initiator. Something like :

diff --git a/packages/client/lib/client/index.ts b/packages/client/lib/client/index.ts
index 5dae1271ec..c6ed508202 100644
--- a/packages/client/lib/client/index.ts
+++ b/packages/client/lib/client/index.ts
@@ -410,7 +410,7 @@ export default class RedisClient<
     });
   }
 
-  async #handshake(selectedDB: number) {
+  async #createHandshakeCommands(selectedDB: number) {
     const commands = [];
     const cp = this.#options?.credentialsProvider;
 
@@ -494,10 +494,38 @@ export default class RedisClient<
         parseArgs(COMMANDS.READONLY)
       );
     }
+    
+    
+    if(this.options?.credentialsProvider) {
+      commands.push()
+    }
 
     return commands;
   }
 
+  async #handshake(selectedDB: number) {
+    const commands = await this.#createHandshakeCommands(selectedDB);
+    const promises = [];
+    const chainId = Symbol('Handshake');
+
+    // Preserve the original reverse order iteration
+    for (let i = commands.length - 1; i >= 0; --i) {
+      promises.push(
+        this.#queue.addCommand(commands[i], {
+          chainId,
+          asap: true
+        })
+      );
+    }
+
+    if (promises.length) {
+      this.#write();
+      return Promise.all(promises);
+    }
+    
+    return Promise.resolve();
+  }
+
   #initiateSocket(): RedisSocket {
     const socketInitiator = async () => {
       const promises = [],
@@ -521,15 +549,8 @@ export default class RedisClient<
         );
       }
 
-      const commands = await this.#handshake(this.#selectedDB);
-      for (let i = commands.length - 1; i >= 0; --i) {
-        promises.push(
-          this.#queue.addCommand(commands[i], {
-            chainId,
-            asap: true
-          })
-        );
-      }
+      const handshakePromise = this.#handshake(this.#selectedDB);
+      promises.push(handshakePromise);
 
       if (promises.length) {
         this.#write();

What do you think ?

@nkaradzhov nkaradzhov force-pushed the bring-disableclientinfo-back branch from 1251554 to d5de30a Compare May 15, 2025 16:01
@nkaradzhov
Copy link
Collaborator Author

@bobymicroby the option to move the setinfo commands in the #getHandshakeCommands method looks to be the most clean

@nkaradzhov nkaradzhov marked this pull request as ready for review May 19, 2025 12:00
@nkaradzhov nkaradzhov requested a review from bobymicroby May 19, 2025 12:00
@nkaradzhov nkaradzhov force-pushed the bring-disableclientinfo-back branch from d5de30a to d70448f Compare May 20, 2025 06:42
Copy link
Member

@bobymicroby bobymicroby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@htemelski htemelski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@nkaradzhov nkaradzhov merged commit 4a5f879 into redis:master May 20, 2025
11 checks passed
@nkaradzhov nkaradzhov deleted the bring-disableclientinfo-back branch May 20, 2025 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

disableClientInfo option is gone in v5
3 participants