- Version: master (e7ff00d)
- Platform: All
- Subsystem: stream
1e0f331 introduced an issue where the end event isn't emitted.
The following test case can reproduce it:
'use strict'conststream=require('stream')classReadableArrayextendsstream.Readable{constructor(data){super({objectMode: true})this._data=data}_read(size){if(this._data.length===0)returnthis.push(null);this.push(this._data.shift());}}classPassThroughAsWrapperextendsstream.Readable{constructor(readable){super({objectMode: true})this._readable=readablethis._readable.once('end',()=>this.push(null))}_read(size){constdata=this._readable.read()if(data===null){this._readable.once('readable',()=>{constdata=this._readable.read()// this reads null, but somehow the end event is not emittedif(data!==null)returnthis.push(data)// end event handler will call .push()})}else{returnthis.push(data)}}}constinputData=[{},{}]constreadable=newReadableArray(inputData)letendEvent=falseconstresult=newPassThroughAsWrapper(readable.pipe(newstream.PassThrough({objectMode: true})))result.once('end',function(){endEvent=true;console.log('end event');})result.resume()process.on('exit',function(){if(!endEvent)console.log('no end event')})The expected result is end event the actual result is no end event.
/cc @mcollina@mafintosh
1e0f331 introduced an issue where the
endevent isn't emitted.The following test case can reproduce it:
The expected result is
end eventthe actual result isno end event./cc @mcollina@mafintosh