@@ -235,6 +235,20 @@ describe('Cluster', () => {
235
235
236
236
assert . equal ( cluster . pubSubNode , undefined ) ;
237
237
} , GLOBAL . CLUSTERS . OPEN ) ;
238
+
239
+ testUtils . testWithCluster ( 'concurrent unsubscribe does not throw an error' , async cluster => {
240
+ const listener = spy ( ) ;
241
+
242
+ await cluster . subscribe ( 'channel' , listener ) ;
243
+ await cluster . subscribe ( 'channel2' , listener ) ;
244
+
245
+ await Promise . all ( [
246
+ cluster . unsubscribe ( 'channel' , listener ) ,
247
+ cluster . unsubscribe ( 'channel2' , listener )
248
+ ] ) ;
249
+
250
+ assert . equal ( cluster . isOpen , false ) ;
251
+ } , GLOBAL . CLUSTERS . OPEN ) ;
238
252
239
253
testUtils . testWithCluster ( 'psubscribe & punsubscribe' , async cluster => {
240
254
const listener = spy ( ) ;
@@ -323,6 +337,24 @@ describe('Cluster', () => {
323
337
minimumDockerVersion : [ 7 ]
324
338
} ) ;
325
339
340
+ testUtils . testWithCluster ( 'concurrent sunsubscribe does not throw an error' , async cluster => {
341
+ const listener = spy ( ) ;
342
+
343
+ await cluster . sSubscribe ( 'channel' , listener ) ;
344
+ await cluster . sSubscribe ( 'channel2' , listener ) ;
345
+
346
+ await Promise . all ( [
347
+ cluster . sUnsubscribe ( 'channel' , listener ) ,
348
+ cluster . sUnsubscribe ( 'channel2' , listener )
349
+ ] )
350
+
351
+
352
+ assert . equal ( cluster . isOpen , false ) ;
353
+ } , {
354
+ ...GLOBAL . CLUSTERS . OPEN ,
355
+ minimumDockerVersion : [ 7 ]
356
+ } ) ;
357
+
326
358
testUtils . testWithCluster ( 'should handle sharded-channel-moved events' , async cluster => {
327
359
const SLOT = 10328 ,
328
360
migrating = cluster . slots [ SLOT ] . master ,
0 commit comments