@@ -17,8 +17,6 @@ const debug = Debug("connection");
1717
1818export 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