node-archiver: Throws error in node v8.0.0
Code:
const archive = archiver.create(`zip`, {});
archive.append(`test`, { name: `test.pdf` });
archive.finalize();
const writeStream = createWriteStream(`test.zip`);
await new Promise(function(resolve, reject) {
writeStream.on(`close`, function() {
console.log(archive.pointer() + ` total bytes`);
console.log(`archiver has been finalized and the output file descriptor has closed.`);
resolve();
});
writeStream.on(`error`, reject);
archive.pipe(writeStream);
});
Throws:
_stream_readable.js:545
switch (state.pipesCount) {
^
TypeError: Cannot read property 'pipesCount' of undefined
at module.exports.Readable.pipe (_stream_readable.js:545:16)
at module.exports.ZipArchiveOutputStream._smartStream (/Users/.../node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js:184:11)
at module.exports.ZipArchiveOutputStream._appendBuffer (/Users/.../node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js:82:10)
at module.exports.ArchiveOutputStream.entry (/Users/.../node_modules/compress-commons/lib/archivers/archive-output-stream.js:86:10)
at module.exports.ZipStream.entry (/Users/.../node_modules/zip-stream/index.js:138:49)
at Zip.append (/Users/.../node_modules/archiver/lib/plugins/zip.js:53:15)
at Archiver._moduleAppend (/Users/.../node_modules/archiver/lib/core.js:172:16)
at Archiver._onQueueTask (/Users/.../node_modules/archiver/lib/core.js:370:8)
at /Users/.../node_modules/async/dist/async.js:4045:9
at process (/Users/.../node_modules/async/dist/async.js:2316:17)
at Immediate._onImmediate (/Users/.../node_modules/async/dist/async.js:66:16)
at runCallback (timers.js:800:20)
at tryOnImmediate (timers.js:762:5)
at processImmediate [as _immediateCallback] (timers.js:733:5)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 40
- Comments: 22 (5 by maintainers)
Commits related to this issue
- regression bug in NodeJS 8 ziplib, sticking to v7 for now (https://github.com/archiverjs/node-compress-commons/issues/25#issuecomment-306478128 and https://github.com/archiverjs/node-archiver/issues/2... — committed to readium/readium-js-viewer by danielweck 7 years ago
- Use node 7 because of bug in 8.0 https://github.com/archiverjs/node-archiver/issues/236 — committed to markdreyer/rallyrap by markdreyer 7 years ago
Yep. The patch already landed in core and 8.1 is coming out tomorrow with the fix.
Is resolved on node 8.1.2
i’m leaning on
zip
andchild_process
for now, ie:before:
after:
i’m following along with this and will work with node team as needed, seems crc32-stream may be added their testbed due to its popularity/dep usage to catch breakages earlier.
i believe it was the refactoring of the zlib class that caused this (that was in the changelog)
For now installed Node 6.10.3 LTS to bypass the issue for the time being until a fix for v 8.0.0 is available. It worked!
We may need to wait for this patch(https://github.com/nodejs/node/pull/13374) in Node.js core to fix this issue. Since the PR got some approved already, I think the patch will be landed in the next build(@jasnell is working on it https://github.com/nodejs/node/pull/13322#issuecomment-305676452).
As @ctalkington said, to not make this happen again, we’re going to keep our eyes on the module with citgm: https://github.com/nodejs/citgm/pull/430.
They moved zlib library to classes. Now in fallback process. I guess today/tomorrow will be fixed. https://github.com/nodejs/node/pull/13370
One of the reasons why it doesn’t work is this commit: https://github.com/nodejs/node/commit/8e69f7e38552a4c65064f2829d9ca973ad9b05ba. In v8.0.0,
zlib.DeflateRaw
is a class instead of a function, and we can’t succeed it on the protype’s way.Same Issue here with node.js v8
For anyone tracking this, here’s a link to the 8.1.0 Proposal pull request.
https://github.com/nodejs/node/pull/13483