@@ -235,6 +235,18 @@ describe('Cluster', () => {
235235
236236 assert . equal ( cluster . pubSubNode , undefined ) ;
237237 } , GLOBAL . CLUSTERS . OPEN ) ;
238+
239+ testUtils . testWithCluster ( 'concurrent UNSUBSCRIBE does not throw an error (#2685)' , async cluster => {
240+ const listener = spy ( ) ;
241+ await Promise . all ( [
242+ cluster . subscribe ( '1' , listener ) ,
243+ cluster . subscribe ( '2' , listener )
244+ ] ) ;
245+ await Promise . all ( [
246+ cluster . unsubscribe ( '1' , listener ) ,
247+ cluster . unsubscribe ( '2' , listener )
248+ ] ) ;
249+ } , GLOBAL . CLUSTERS . OPEN ) ;
238250
239251 testUtils . testWithCluster ( 'psubscribe & punsubscribe' , async cluster => {
240252 const listener = spy ( ) ;
@@ -323,6 +335,21 @@ describe('Cluster', () => {
323335 minimumDockerVersion : [ 7 ]
324336 } ) ;
325337
338+ testUtils . testWithCluster ( 'concurrent SUNSUBCRIBE does not throw an error (#2685)' , async cluster => {
339+ const listener = spy ( ) ;
340+ await Promise . all ( [
341+ await cluster . sSubscribe ( '1' , listener ) ,
342+ await cluster . sSubscribe ( '2' , listener )
343+ ] ) ;
344+ await Promise . all ( [
345+ cluster . sUnsubscribe ( '1' , listener ) ,
346+ cluster . sUnsubscribe ( '2' , listener )
347+ ] ) ;
348+ } , {
349+ ...GLOBAL . CLUSTERS . OPEN ,
350+ minimumDockerVersion : [ 7 ]
351+ } ) ;
352+
326353 testUtils . testWithCluster ( 'should handle sharded-channel-moved events' , async cluster => {
327354 const SLOT = 10328 ,
328355 migrating = cluster . slots [ SLOT ] . master ,
0 commit comments