File tree 2 files changed +23
-3
lines changed
2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -185,13 +185,13 @@ export class uServer extends BaseServer {
185
185
const client = this . clients [ id ] ;
186
186
if ( ! client ) {
187
187
debug ( "upgrade attempt for closed client" ) ;
188
- res . close ( ) ;
188
+ return res . close ( ) ;
189
189
} else if ( client . upgrading ) {
190
190
debug ( "transport has already been trying to upgrade" ) ;
191
- res . close ( ) ;
191
+ return res . close ( ) ;
192
192
} else if ( client . upgraded ) {
193
193
debug ( "transport had already been upgraded" ) ;
194
- res . close ( ) ;
194
+ return res . close ( ) ;
195
195
} else {
196
196
debug ( "upgrading existing transport" ) ;
197
197
transport = this . createTransport ( req . _query . transport , req ) ;
Original file line number Diff line number Diff line change @@ -205,6 +205,26 @@ describe("server", () => {
205
205
} ) ;
206
206
} ) ;
207
207
208
+ it ( "should prevent the client from upgrading twice" , ( done ) => {
209
+ engine = listen ( ( port ) => {
210
+ const client = new ClientSocket ( `ws://localhost:${ port } ` ) ;
211
+
212
+ client . on ( "upgrade" , ( ) => {
213
+ const socket = new WebSocket (
214
+ `ws://localhost:${ port } /engine.io/?EIO=4&transport=websocket&sid=${ client . id } ` ,
215
+ ) ;
216
+
217
+ socket . on ( "error" , ( ) => { } ) ;
218
+
219
+ socket . on ( "close" , ( ) => {
220
+ client . close ( ) ;
221
+
222
+ done ( ) ;
223
+ } ) ;
224
+ } ) ;
225
+ } ) ;
226
+ } ) ;
227
+
208
228
it ( "should disallow `__proto__` as transport (polling)" , ( done ) => {
209
229
const partialDone = createPartialDone ( done , 2 ) ;
210
230
You can’t perform that action at this time.
0 commit comments