@@ -560,10 +560,11 @@ function processCallback() {
560
560
self . bytesWritten += inDelta ;
561
561
562
562
const have = handle . availOutBefore - availOutAfter ;
563
+ let streamBufferIsFull = false ;
563
564
if ( have > 0 ) {
564
565
const out = self . _outBuffer . slice ( self . _outOffset , self . _outOffset + have ) ;
565
566
self . _outOffset += have ;
566
- self . push ( out ) ;
567
+ streamBufferIsFull = ! self . push ( out ) ;
567
568
} else {
568
569
assert ( have === 0 , 'have should not go down' ) ;
569
570
}
@@ -588,13 +589,29 @@ function processCallback() {
588
589
handle . inOff += inDelta ;
589
590
handle . availInBefore = availInAfter ;
590
591
591
- this . write ( handle . flushFlag ,
592
- this . buffer , // in
593
- handle . inOff , // in_off
594
- handle . availInBefore , // in_len
595
- self . _outBuffer , // out
596
- self . _outOffset , // out_off
597
- self . _chunkSize ) ; // out_len
592
+
593
+ if ( ! streamBufferIsFull ) {
594
+ this . write ( handle . flushFlag ,
595
+ this . buffer , // in
596
+ handle . inOff , // in_off
597
+ handle . availInBefore , // in_len
598
+ self . _outBuffer , // out
599
+ self . _outOffset , // out_off
600
+ self . _chunkSize ) ; // out_len
601
+ } else {
602
+ const oldRead = self . _read ;
603
+ self . _read = ( n ) => {
604
+ self . _read = oldRead ;
605
+ this . write ( handle . flushFlag ,
606
+ this . buffer , // in
607
+ handle . inOff , // in_off
608
+ handle . availInBefore , // in_len
609
+ self . _outBuffer , // out
610
+ self . _outOffset , // out_off
611
+ self . _chunkSize ) ; // out_len
612
+ self . _read ( n ) ;
613
+ } ;
614
+ }
598
615
return ;
599
616
}
600
617
0 commit comments