File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
packages/socket.io-client Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,9 @@ export class Manager<
201201 public reconnection ( v ?: boolean ) : this | boolean {
202202 if ( ! arguments . length ) return this . _reconnection ;
203203 this . _reconnection = ! ! v ;
204+ if ( ! v ) {
205+ this . skipReconnect = true ;
206+ }
204207 return this ;
205208 }
206209
Original file line number Diff line number Diff line change @@ -520,6 +520,28 @@ describe("connection", () => {
520520 } ) ;
521521 } ) ;
522522
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+
523545 // Ignore incorrect connection test for old IE due to no support for
524546 // `script.onerror` (see: http://requirejs.org/docs/api.html#ieloadfail)
525547 if ( ! global . document || hasCORS ) {
You can’t perform that action at this time.
0 commit comments