@@ -3776,8 +3776,7 @@ describe("PubSub", () => {
37763776 return ; // Skip test if server version is less than required
37773777 }
37783778
3779- let pubSub : GlideClusterClientConfiguration . PubSubSubscriptions | null =
3780- null ;
3779+ let pubSub : GlideClusterClientConfiguration . PubSubSubscriptions | null = null ;
37813780 let client1 : TGlideClient | null = null ;
37823781 let client2 : TGlideClient | null = null ;
37833782 let client : TGlideClient | null = null ;
@@ -3811,15 +3810,26 @@ describe("PubSub", () => {
38113810 pubSub ,
38123811 ) ;
38133812
3814- // Test pubsubShardchannels without pattern
3815- const channels = await (
3816- client2 as GlideClusterClient
3817- ) . pubsubShardChannels ( ) ;
3818- expect ( new Set ( channels ) ) . toEqual (
3819- new Set ( [ channel1 , channel2 , channel3 ] ) ,
3820- ) ;
3821-
3822- // Test pubsubShardchannels with pattern
3813+ {
3814+ // Wait up to 3 seconds (60 * 50ms)
3815+ for ( let i = 0 ; i < 60 ; i ++ ) {
3816+ try {
3817+ const channels = await ( client2 as GlideClusterClient ) . pubsubShardChannels ( ) ;
3818+ if ( channels . length === 3 ) {
3819+ break ;
3820+ }
3821+ } catch ( e ) {
3822+ }
3823+ await new Promise ( ( r ) => setTimeout ( r , 50 ) ) ;
3824+ }
3825+ const channels = await (
3826+ client2 as GlideClusterClient
3827+ ) . pubsubShardChannels ( ) ;
3828+
3829+ expect ( new Set ( channels ) ) . toEqual (
3830+ new Set ( [ channel1 , channel2 , channel3 ] ) ,
3831+ ) ;
3832+ }
38233833 const channelsWithPattern = await (
38243834 client2 as GlideClusterClient
38253835 ) . pubsubShardChannels ( { pattern } ) ;
0 commit comments