File tree 2 files changed +25
-0
lines changed
packages/socket.io-client
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,9 @@ export class Manager<
201
201
public reconnection ( v ?: boolean ) : this | boolean {
202
202
if ( ! arguments . length ) return this . _reconnection ;
203
203
this . _reconnection = ! ! v ;
204
+ if ( ! v ) {
205
+ this . skipReconnect = true ;
206
+ }
204
207
return this ;
205
208
}
206
209
Original file line number Diff line number Diff line change @@ -520,6 +520,28 @@ describe("connection", () => {
520
520
} ) ;
521
521
} ) ;
522
522
523
+ it ( "should stop trying to reconnect" , ( ) => {
524
+ return wrap ( ( done ) => {
525
+ const manager = new Manager ( "http://localhost:9823" , {
526
+ reconnectionDelay : 10 ,
527
+ } ) ;
528
+
529
+ manager . on ( "reconnect_error" , ( ) => {
530
+ // disable current reconnection loop
531
+ manager . reconnection ( false ) ;
532
+
533
+ manager . on ( "reconnect_attempt" , ( ) => {
534
+ done ( new Error ( "should not happen" ) ) ;
535
+ } ) ;
536
+
537
+ setTimeout ( ( ) => {
538
+ manager . _close ( ) ;
539
+ done ( ) ;
540
+ } , 100 ) ;
541
+ } ) ;
542
+ } ) ;
543
+ } ) ;
544
+
523
545
// Ignore incorrect connection test for old IE due to no support for
524
546
// `script.onerror` (see: http://requirejs.org/docs/api.html#ieloadfail)
525
547
if ( ! global . document || hasCORS ) {
You can’t perform that action at this time.
0 commit comments