File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -322,6 +322,7 @@ export class Socket<
322
322
break ;
323
323
324
324
case PacketType . CONNECT_ERROR :
325
+ this . destroy ( ) ;
325
326
const err = new Error ( packet . data . message ) ;
326
327
// @ts -ignore
327
328
err . data = packet . data . data ;
Original file line number Diff line number Diff line change @@ -214,6 +214,23 @@ describe("socket", function () {
214
214
} ) ;
215
215
} ) ;
216
216
217
+ it ( "should not try to reconnect after a middleware failure" , ( done ) => {
218
+ const socket = io ( "/no" , { forceNew : true , reconnectionDelay : 10 } ) ;
219
+
220
+ let count = 0 ;
221
+
222
+ socket . on ( "connect_error" , ( ) => {
223
+ count ++ ;
224
+ // force reconnection
225
+ socket . io . engine . close ( ) ;
226
+ } ) ;
227
+
228
+ setTimeout ( ( ) => {
229
+ expect ( count ) . to . eql ( 1 ) ;
230
+ done ( ) ;
231
+ } , 100 ) ;
232
+ } ) ;
233
+
217
234
it ( "should throw on reserved event" , ( ) => {
218
235
const socket = io ( "/no" , { forceNew : true } ) ;
219
236
You can’t perform that action at this time.
0 commit comments