- Version: v14.0.0
- Platform:
Linux solus 5.5.11-151.current #1 SMP PREEMPT Tue Mar 24 18:06:46 UTC 2020 x86_64 GNU/Linux - Subsystem: stream
What steps will reproduce the bug?
const{Duplex, PassThrough}=require('stream');constresponse=newPassThrough();setTimeout(()=>response.write('chunk 1'),500);setTimeout(()=>response.write('chunk 2'),1000);setTimeout(()=>response.write('chunk 3'),1500);setTimeout(()=>response.end(),2000);classHelloWorldextendsDuplex{constructor(response){super();this.response=response;this.readMore=false;response.once('end',()=>{this.push(null);});response.on('readable',()=>{if(this.readMore){this._read();}});}_read(){const{response}=this;this.readMore=true;if(response.readableLength){this.readMore=false;}letdata;while((data=response.read())!==null){this.push(data);}}}constinstance=newHelloWorld(response);instance.end();(async()=>{awaitnewPromise(resolve=>setTimeout(resolve,100));forawait(constdataofinstance){console.log(data.toString());}console.log('finished await');})();How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
chunk 1
chunk 2
chunk 3
finished await
What do you see instead?
Additional information
Async iterator utilizes the end-of-stream module. The culprit is this:
| (wState&&wState.finished)||(rState&&rState.endEmitted)|| |
wState.finished is true, therefore the callback is called even though it should not.
Original Got issue: sindresorhus/got#1172
Linux solus 5.5.11-151.current #1 SMP PREEMPT Tue Mar 24 18:06:46 UTC 2020 x86_64 GNU/LinuxWhat steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
What do you see instead?
Additional information
Async iterator utilizes the
end-of-streammodule. The culprit is this:node/lib/internal/streams/end-of-stream.js
Line 152 in f64c640
wState.finishedistrue, therefore the callback is called even though it should not.Original Got issue: sindresorhus/got#1172