Closed tex0l closed 4 years ago
Impressive debugging. I had completely missed that this BC in node could affect this behaviour. Well done.
Thanks! I disabled the travis check cause that's not part of our supported API, but happy to add this as it helps with rollup
2.1.3
Fair enough, thank you!
Oh my goodness I am so glad someone PR'd this change! I spent ages a couple weeks ago coming to the same fix, should have thought to PR it at the time. Way to go @tex0l!
The reason why
tar-stream
breaks with node@14 native streams is because of this feature introduced in node v14.0.0: https://github.com/saitonakamura/node/commit/b004ac0edf815d6bd3dd9cdaa8c24be3f72cff82Basically, when calling the
end
method on aWritable
stream, it triggers its destruction by default, which was not the case in earlier versions.In
tar-stream
, the reason why it causes an issue is that there are as manySource
streams as there are entries. Each of those arePassThrough
streams with an offset on theExtract
stream. When the first entry ends, it consequently triggers the destruction of thisSource
stream, which is manually forwarded to the parent stream:https://github.com/mafintosh/tar-stream/blob/81cd7390f091244a51e0ea67be3c454352f8b366/extract.js#L37-L39
which destroys the
Extract
stream without triggering neither an error nor thefinished
event.By setting an
autoDestroy: false
when instantiating theSource
stream it forces the same behaviour as in previous versions of node, and does not break anything.I've updated the travis-ci configuration to test against node up to v14, and to test with native implementations of streams starting from node 8 (I've tried using the native streams on node@6, it breaks).