-
Notifications
You must be signed in to change notification settings - Fork 7.3k
zlib auto-reset on trailing data causes repeated flushing #8962
Comments
Per @othiym23, this seems like a pretty severe regression:
|
It seems that any file in an npm tarball that's more than one stream-chunk long will trigger this behavior in |
A semi-related reproduction. Before the patch, this code would write once and then halt -- afterward, it errors (so, that's one breaking change). I've come around to the idea that zlib's transform streams shouldn't transparently handle decompressing concatenated compressed streams -- really, an outer stream should be in charge of that, and all node should be concerned with is giving the client the leftover bytes so they can manually |
Update: An actual reproduction! |
Made a patch to fix the reproduction. Unfortunately npm still blows up with this patch, though at least it's ending the stream now. npm encounters the following error:
Since there are trailing "zero" bytes in the tar.gz it's trying to decompress, it blows up when trying to restart the stream. Edit: those trailing zeros may be due to block-stream. |
/cc @luismreis, who originally authored the patch. |
I suppose the remaining questions are:
|
I had to rollback my CI environments to work around this. I couldn't run @chrisdickinson your proposal to revert for now (0.11.15, I'm guessing?) and reintroduce later as an opt-in option sounds reasonable to me. |
Revert "src: fix windows build error" and "zlib: support concatenated gzip files". Treating subsequent data as a concatenated stream breaks npm install. This reverts commits 93533e9 and 6f6a979. Fixes: nodejs#8962 PR-URL: nodejs#8985 Reviewed-By: Julien Gilli <[email protected]>
Revert "src: fix windows build error" and "zlib: support concatenated gzip files". Treating subsequent data as a concatenated stream breaks npm install. This reverts commits 93533e9 and 6f6a979. Fixes: #8962 PR-URL: #8985 Reviewed-By: Julien Gilli <[email protected]>
Fixed by c8ef97e. |
Hi, can you tell what's the reason for the gunzip transform stream being fed with data that is not gzipped ? According to the gzip spec, we should be reading it as if it was a new gzipped stream, but it seams not to be the case here. Does it make any sense to trim the stream from npm ? I would like to help, but I'm feeling a bit lost here. |
Revert "src: fix windows build error" and "zlib: support concatenated gzip files". This reverts commits be413ac and 1183ba4. Treating subsequent bytes as a concatenated zlib stream breaks npm install. Conflicts: test/parallel/test-zlib-from-multiple-gzip-with-garbage.js test/parallel/test-zlib-from-multiple-gzip.js test/parallel/test-zlib-from-multiple-huge-gzip.js Fixes: nodejs/node-v0.x-archive#8962 PR-URL: #240 Reviewed-By: Ben Noordhuis <[email protected]>
@chrisdickinson, @othiym23 I'd like to fix this and have a proper patch commited into node/iojs. The example referenced in #8962 (comment), converted to bash is something like:
Which yields for output:
The equivalent code in perl
Output:
So, what should be the proper behaviour of this patch ? Should it try to decode the next stream ? Should it passed it along transparently ? Should it ignore it ?
|
6f6a979 changed the behavior of the zlib module's decompression transform (specifically
Zlib.prototype._processChunk
): if an incoming chunk would end the transform, but has trailing data, the transform resets itself and re-sends the chunk, optimistically assuming that the chunk represents a concatenated stream. However, it looks like this behavior can hang Node, and breaks some tests in npm. I'm looking into this at present, but want to make others aware!The text was updated successfully, but these errors were encountered: