You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.on('close') for a readable stream stops working when going from node 12.14.0 to 12.16.1 #32023
functiongetGzipSize(filePath){letbytesWritten=0;constbyteCounter=newWritable({write(chunk,encoding,callback){// we control the input stream, will always be a BufferbytesWritten+=chunk.length;callback();},});returnnewPromise((res,rej)=>{fs.createReadStream(filePath).pipe(zlib.createGzip({level: 9}))// writable streams do not fire the 'close' event anymore// https://github.com/nodejs/node/issues/21122#issuecomment-414622251.on('close',()=>res(bytesWritten)).pipe(byteCounter).on('error',rej);});}
Switch to Node 12.16.1
How often does it reproduce? Is there a required condition?
Consistently.
What is the expected behavior?
With this certain piece of code, on close of the stream, a markdown file should be printed.
What do you see instead?
Nothing is printed due to it not closing.
Additional information
Switching close to end makes it work. Also, this comes from a discussion I had with @mcollina and @jasnell on Twitter.
Activity
Hakerh400 commentedon Mar 1, 2020
bisected to 7cad756
Trott commentedon Mar 1, 2020
@addaleax
zlib: emits 'close' event after readble 'end'
zlib: emits 'close' event after readable 'end'
zlib: emits 'close' event after readable 'end'
zlib: emits 'close' event after readable 'end'
zlib: emits 'close' event after readable 'end'