File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed
packages/client/lib/client Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -51,11 +51,9 @@ Looking for a high-level library to handle object mapping? See [redis-om-node](h
5151``` typescript
5252import { createClient } from ' redis' ;
5353
54- const client = createClient ();
55-
56- client .on (' error' , err => console .log (' Redis Client Error' , err ));
57-
58- await client .connect ();
54+ const client = await createClient ()
55+ .on (' error' , err => console .log (' Redis Client Error' , err ))
56+ .connect ();
5957
6058await client .set (' key' , ' value' );
6159const value = await client .get (' key' );
Original file line number Diff line number Diff line change @@ -107,6 +107,19 @@ describe('Client', () => {
107107 } ) ;
108108 } ) ;
109109
110+ describe ( 'connect' , ( ) => {
111+ testUtils . testWithClient ( 'connect should return the client instance' , async client => {
112+ try {
113+ assert . equal ( await client . connect ( ) , client ) ;
114+ } finally {
115+ if ( client . isOpen ) await client . disconnect ( ) ;
116+ }
117+ } , {
118+ ...GLOBAL . SERVERS . PASSWORD ,
119+ disableClientSetup : true
120+ } ) ;
121+ } ) ;
122+
110123 describe ( 'authentication' , ( ) => {
111124 testUtils . testWithClient ( 'Client should be authenticated' , async client => {
112125 assert . equal (
Original file line number Diff line number Diff line change @@ -426,10 +426,11 @@ export default class RedisClient<
426426 } ) ;
427427 }
428428
429- connect ( ) : Promise < void > {
429+ async connect ( ) {
430430 // see comment in constructor
431431 this . #isolationPool ??= this . #initiateIsolationPool( ) ;
432- return this . #socket. connect ( ) ;
432+ await this . #socket. connect ( ) ;
433+ return this as unknown as RedisClientType < M , F , S > ;
433434 }
434435
435436 async commandsExecutor < C extends RedisCommand > (
You can’t perform that action at this time.
0 commit comments