@@ -279,9 +279,13 @@ HttpProxy.prototype.proxyRequest = function (req, res, buffer) {
279
279
}
280
280
} ) ;
281
281
282
+ //
282
283
// If we have been passed buffered data, resume it.
283
- if ( buffer && ! errState ) {
284
- buffer . resume ( ) ;
284
+ //
285
+ if ( buffer ) {
286
+ return ! errState
287
+ ? buffer . resume ( )
288
+ : buffer . destroy ( ) ;
285
289
}
286
290
} ;
287
291
@@ -419,6 +423,7 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
419
423
reverseProxy . incoming . socket . write ( data ) ;
420
424
}
421
425
catch ( ex ) {
426
+ detach ( ) ;
422
427
reverseProxy . incoming . socket . end ( ) ;
423
428
proxySocket . end ( ) ;
424
429
}
@@ -429,12 +434,13 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
429
434
// Any outgoing data on this Websocket from the proxy target
430
435
// will be written to the `proxySocket` socket.
431
436
//
432
- reverseProxy . incoming . socket . on ( 'data' , listeners . onOutgoing = function ( data ) {
437
+ reverseProxy . incoming . socket . on ( 'data' , listeners . onOutgoing = function ( data ) {
433
438
try {
434
439
self . emit ( 'websocket:incoming' , reverseProxy , reverseProxy . incoming , head , data ) ;
435
440
proxySocket . write ( data ) ;
436
441
}
437
442
catch ( ex ) {
443
+ detach ( ) ;
438
444
proxySocket . end ( ) ;
439
445
socket . end ( ) ;
440
446
}
@@ -625,7 +631,9 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
625
631
//
626
632
// If we have been passed buffered data, resume it.
627
633
//
628
- if ( buffer && ! errState ) {
629
- buffer . resume ( ) ;
634
+ if ( buffer ) {
635
+ return ! errState
636
+ ? buffer . resume ( )
637
+ : buffer . destroy ( ) ;
630
638
}
631
639
} ;
0 commit comments