File tree 2 files changed +33
-4
lines changed
2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -113,15 +113,16 @@ export class Client {
113
113
* @private
114
114
*/
115
115
private doConnect ( name : string , auth : object ) {
116
- if ( this . connectTimeout ) {
117
- clearTimeout ( this . connectTimeout ) ;
118
- this . connectTimeout = undefined ;
119
- }
120
116
const nsp = this . server . of ( name ) ;
121
117
122
118
const socket = nsp . _add ( this , auth , ( ) => {
123
119
this . sockets . set ( socket . id , socket ) ;
124
120
this . nsps . set ( nsp . name , socket ) ;
121
+
122
+ if ( this . connectTimeout ) {
123
+ clearTimeout ( this . connectTimeout ) ;
124
+ this . connectTimeout = undefined ;
125
+ }
125
126
} ) ;
126
127
}
127
128
@@ -277,5 +278,10 @@ export class Client {
277
278
this . conn . removeListener ( "close" , this . onclose ) ;
278
279
// @ts -ignore
279
280
this . decoder . removeListener ( "decoded" , this . ondecoded ) ;
281
+
282
+ if ( this . connectTimeout ) {
283
+ clearTimeout ( this . connectTimeout ) ;
284
+ this . connectTimeout = undefined ;
285
+ }
280
286
}
281
287
}
Original file line number Diff line number Diff line change @@ -774,6 +774,29 @@ describe("socket.io", () => {
774
774
} ) ;
775
775
} ) ;
776
776
777
+ it ( "should close a client without namespace" , ( done ) => {
778
+ const srv = createServer ( ) ;
779
+ const sio = new Server ( srv , {
780
+ connectTimeout : 100 ,
781
+ } ) ;
782
+
783
+ sio . use ( ( _ , next ) => {
784
+ next ( new Error ( "nope" ) ) ;
785
+ } ) ;
786
+
787
+ srv . listen ( ( ) => {
788
+ const socket = client ( srv ) ;
789
+
790
+ const success = ( ) => {
791
+ socket . close ( ) ;
792
+ sio . close ( ) ;
793
+ done ( ) ;
794
+ } ;
795
+
796
+ socket . on ( "disconnect" , success ) ;
797
+ } ) ;
798
+ } ) ;
799
+
777
800
describe ( "dynamic namespaces" , ( ) => {
778
801
it ( "should allow connections to dynamic namespaces with a regex" , ( done ) => {
779
802
const srv = createServer ( ) ;
You can’t perform that action at this time.
0 commit comments