@@ -115,6 +115,8 @@ Transport.prototype.setHandlers = function () {
115
115
this . socket . on ( 'close' , this . bound . close ) ;
116
116
this . socket . on ( 'error' , this . bound . error ) ;
117
117
this . socket . on ( 'drain' , this . bound . drain ) ;
118
+
119
+ this . handlersSet = true ;
118
120
} ;
119
121
120
122
/**
@@ -124,14 +126,16 @@ Transport.prototype.setHandlers = function () {
124
126
*/
125
127
126
128
Transport . prototype . clearHandlers = function ( ) {
127
- this . store . unsubscribe ( 'disconnect-force:' + this . id ) ;
128
- this . store . unsubscribe ( 'heartbeat-clear:' + this . id ) ;
129
- this . store . unsubscribe ( 'dispatch:' + this . id ) ;
130
-
131
- this . socket . removeListener ( 'end' , this . bound . end ) ;
132
- this . socket . removeListener ( 'close' , this . bound . close ) ;
133
- this . socket . removeListener ( 'error' , this . bound . error ) ;
134
- this . socket . removeListener ( 'drain' , this . bound . drain ) ;
129
+ if ( this . handlersSet ) {
130
+ this . store . unsubscribe ( 'disconnect-force:' + this . id ) ;
131
+ this . store . unsubscribe ( 'heartbeat-clear:' + this . id ) ;
132
+ this . store . unsubscribe ( 'dispatch:' + this . id ) ;
133
+
134
+ this . socket . removeListener ( 'end' , this . bound . end ) ;
135
+ this . socket . removeListener ( 'close' , this . bound . close ) ;
136
+ this . socket . removeListener ( 'error' , this . bound . error ) ;
137
+ this . socket . removeListener ( 'drain' , this . bound . drain ) ;
138
+ }
135
139
} ;
136
140
137
141
/**
0 commit comments