File tree 2 files changed +24
-1
lines changed
2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ module.exports = class BodyReadable extends Readable {
93
93
}
94
94
95
95
push ( chunk ) {
96
- if ( this [ kConsume ] && chunk !== null ) {
96
+ if ( this [ kConsume ] && chunk !== null && this . readableLength === 0 ) {
97
97
consumePush ( this [ kConsume ] , chunk )
98
98
return this [ kReading ] ? super . push ( chunk ) : true
99
99
}
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const { test } = require ( 'tap' )
4
+ const Readable = require ( '../lib/api/readable' )
5
+
6
+ test ( 'avoid body reordering' , async function ( t ) {
7
+ function resume ( ) {
8
+ }
9
+ function abort ( ) {
10
+ }
11
+ const r = new Readable ( resume , abort )
12
+
13
+ r . push ( Buffer . from ( 'hello' ) )
14
+
15
+ process . nextTick ( ( ) => {
16
+ r . push ( Buffer . from ( 'world' ) )
17
+ r . push ( null )
18
+ } )
19
+
20
+ const text = await r . text ( )
21
+
22
+ t . equal ( text , 'helloworld' )
23
+ } )
You can’t perform that action at this time.
0 commit comments