@@ -551,10 +551,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
551
551
}
552
552
}
553
553
if ( ! flushed ) {
554
+ //console.error('backpressure 554');
554
555
response . pause ( ) ;
555
556
res . once ( 'drain' , function ( ) {
556
557
response . resume ( ) ;
557
558
} ) ;
559
+ setTimeout ( function ( ) {
560
+ res . emit ( 'drain' ) ;
561
+ } , 100 ) ;
558
562
}
559
563
} ) ;
560
564
@@ -587,10 +591,14 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
587
591
if ( ! errState ) {
588
592
var flushed = reverseProxy . write ( chunk ) ;
589
593
if ( ! flushed ) {
594
+ //console.error('backpressure 594');
590
595
req . pause ( ) ;
591
596
reverseProxy . once ( 'drain' , function ( ) {
592
597
req . resume ( ) ;
593
598
} ) ;
599
+ setTimeout ( function ( ) {
600
+ reverseProxy . emit ( 'drain' ) ;
601
+ } , 100 ) ;
594
602
}
595
603
}
596
604
} ) ;
@@ -661,10 +669,14 @@ HttpProxy.prototype._forwardRequest = function (req) {
661
669
req . on ( 'data' , function ( chunk ) {
662
670
var flushed = forwardProxy . write ( chunk ) ;
663
671
if ( ! flushed ) {
672
+ //console.error('backpressure 672');
664
673
req . pause ( ) ;
665
674
forwardProxy . once ( 'drain' , function ( ) {
666
675
req . resume ( ) ;
667
676
} ) ;
677
+ setTimeout ( function ( ) {
678
+ forwardProxy . emit ( 'drain' ) ;
679
+ } , 100 ) ;
668
680
}
669
681
} )
670
682
@@ -762,10 +774,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
762
774
self . emit ( 'websocket:outgoing' , req , socket , head , data ) ;
763
775
var flushed = reverseProxy . incoming . socket . write ( data ) ;
764
776
if ( ! flushed ) {
777
+ //console.error('backpressure 777');
765
778
proxySocket . pause ( ) ;
766
779
reverseProxy . incoming . socket . once ( 'drain' , function ( ) {
767
780
proxySocket . resume ( ) ;
768
781
} ) ;
782
+ setTimeout ( function ( ) {
783
+ reverseProxy . incoming . socket . emit ( 'drain' ) ;
784
+ } , 100 ) ;
769
785
}
770
786
}
771
787
catch ( e ) {
@@ -785,10 +801,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
785
801
self . emit ( 'websocket:incoming' , reverseProxy , reverseProxy . incoming , head , data ) ;
786
802
var flushed = proxySocket . write ( data ) ;
787
803
if ( ! flushed ) {
804
+ //console.error('backpressure 804');
788
805
reverseProxy . incoming . socket . pause ( ) ;
789
806
proxySocket . once ( 'drain' , function ( ) {
790
807
reverseProxy . incoming . socket . resume ( ) ;
791
808
} ) ;
809
+ setTimeout ( function ( ) {
810
+ proxySocket . emit ( 'drain' ) ;
811
+ } , 100 ) ;
792
812
}
793
813
}
794
814
catch ( e ) {
@@ -951,10 +971,14 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, options
951
971
socket . write ( sdata ) ;
952
972
var flushed = socket . write ( data ) ;
953
973
if ( ! flushed ) {
974
+ //console.error('backpressure 974');
954
975
reverseProxy . socket . pause ( ) ;
955
976
socket . once ( 'drain' , function ( ) {
956
977
reverseProxy . socket . resume ( ) ;
957
978
} ) ;
979
+ setTimeout ( function ( ) {
980
+ socket . emit ( 'drain' ) ;
981
+ } , 100 ) ;
958
982
}
959
983
960
984
}
0 commit comments