Skip to content

Commit 0869378

Browse files
committed
fix: emit connect once all handshake commands have been resolved
1 parent 105dc72 commit 0869378

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

lib/Redis.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,11 @@ class Redis extends Commander implements DataHandledable {
447447

448448
let writable =
449449
this.status === "ready" ||
450+
(!stream && Command.checkFlag("HANDSHAKE_COMMANDS", command.name)) ||
450451
(!stream &&
451452
this.status === "connect" &&
452453
exists(command.name) &&
453-
(hasFlag(command.name, "loading") ||
454-
Command.checkFlag("HANDSHAKE_COMMANDS", command.name)));
454+
hasFlag(command.name, "loading"));
455455
if (!this.stream) {
456456
writable = false;
457457
} else if (!this.stream.writable) {

lib/redis/event_handler.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ const debug = Debug("connection");
1717

1818
export function connectHandler(self) {
1919
return function () {
20-
self.setStatus("connect");
21-
2220
self.resetCommandQueue();
2321

2422
// AUTH command should be processed before any other commands
@@ -66,15 +64,6 @@ export function connectHandler(self) {
6664
});
6765
}
6866

69-
/*
70-
No need to keep the reference of DataHandler here
71-
because we don't need to do the cleanup.
72-
`Stream#end()` will remove all listeners for us.
73-
*/
74-
new DataHandler(self, {
75-
stringNumbers: self.options.stringNumbers,
76-
});
77-
7867
const clientCommandPromises = [];
7968

8069
if (self.options.connectionName) {
@@ -109,9 +98,21 @@ export function connectHandler(self) {
10998
);
11099
}
111100

101+
/*
102+
No need to keep the reference of DataHandler here
103+
because we don't need to do the cleanup.
104+
`Stream#end()` will remove all listeners for us.
105+
*/
106+
new DataHandler(self, {
107+
stringNumbers: self.options.stringNumbers,
108+
});
109+
112110
Promise.all(clientCommandPromises)
113111
.catch(noop)
114112
.finally(() => {
113+
// Emit connect once all handshake commands have passed
114+
self.setStatus("connect");
115+
115116
if (!self.options.enableReadyCheck) {
116117
exports.readyHandler(self)();
117118
}

0 commit comments

Comments
 (0)