Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throws error in node v8.0.0 #236

Closed
jwhitmarsh opened this issue May 31, 2017 · 22 comments
Closed

Throws error in node v8.0.0 #236

jwhitmarsh opened this issue May 31, 2017 · 22 comments

Comments

@jwhitmarsh
Copy link

jwhitmarsh commented May 31, 2017

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)
@ruslankonev
Copy link

me too

@soyuka
Copy link
Contributor

soyuka commented May 31, 2017

More stacktrace? Weird thing is that it comes from here

@jwhitmarsh
Copy link
Author

@soyuka I've updated the issue with my stacktrace.

@soyuka
Copy link
Contributor

soyuka commented May 31, 2017

Thanks @jwhitmarsh

I can't explain the error though. Archive output stream correctly inherits the Transform stream which should have a _readableState unless node stream inheritance api has changed (AFAIR it has not - only thing added is the destroy method in node 8).

For the ease of debugging the source of the error is zip-archive-output-stream (node-compress-commons). The stream there is using node-crc32-stream which may be part of the bug equation.

@ctalkington any idea on this?

@laurenzlong
Copy link

Same here.

@unipheas
Copy link

I'm not sure if this helps but here goes. I got this error trying to build an Ionic project with all the latest versions and got some extra information.

(node:18146) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error [ERR_IPC_CHANNEL_CLOSED]: channel closed (node:18146) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@watilde
Copy link

watilde commented Jun 1, 2017

One of the reasons why it doesn't work is this commit: nodejs/node@8e69f7e. In v8.0.0, zlib.DeflateRaw is a class instead of a function, and we can't succeed it on the protype's way.

@soyuka
Copy link
Contributor

soyuka commented Jun 1, 2017

Nice catch @watilde any idea on how this can be fixed? The best would be to have some kind of fallback for older nodejs versions :/.

Weird that this didn't show up in nodejs changelog btw.

@goelmk
Copy link

goelmk commented Jun 1, 2017

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!

@jed
Copy link

jed commented Jun 1, 2017

i'm leaning on zip and child_process for now, ie:

before:

var zip = archiver('zip').directory(pathname).finalize()

after:

var zip = child_process.spawn('zip', ['-r', '-', pathname]).stdout

@ctalkington
Copy link
Member

ctalkington commented Jun 2, 2017

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)

@dehimer
Copy link

dehimer commented Jun 2, 2017

They moved zlib library to classes. Now in fallback process. I guess today/tomorrow will be fixed.
nodejs/node#13370

@watilde
Copy link

watilde commented Jun 2, 2017

We may need to wait for this patch(nodejs/node#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 nodejs/node#13322 (comment)).

As @ctalkington said, to not make this happen again, we're going to keep our eyes on the module with citgm: nodejs/citgm#430.

@danielweck
Copy link

Same error with NodeJS v8 on TravisCI (I'm downgrading to NodeJS v7 until this is fixed)

_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 (/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js:184:11)
    at module.exports.ZipArchiveOutputStream._appendStream (/node_modules/compress-commons/lib/archivers/zip/zip-archive-output-stream.js:96:20)
    at module.exports.ArchiveOutputStream.entry (/node_modules/compress-commons/lib/archivers/archive-output-stream.js:88:10)
    at module.exports.ZipStream.entry (/node_modules/zip-stream/index.js:138:49)
    at Zip.append (/node_modules/archiver/lib/plugins/zip.js:53:15)
    at Archiver._moduleAppend (/node_modules/archiver/lib/core.js:172:16)
    at Archiver._onQueueTask (/node_modules/archiver/lib/core.js:370:8)
    at /node_modules/async/dist/async.js:3879:9

@jasnell
Copy link

jasnell commented Jun 6, 2017

Yep. The patch already landed in core and 8.1 is coming out tomorrow with the fix.

@dehimer
Copy link

dehimer commented Jun 6, 2017

Cool, I thought its will be longer

@htoooth
Copy link

htoooth commented Jun 8, 2017

Same here.

@wayneashleyberry
Copy link

For anyone tracking this, here's a link to the 8.1.0 Proposal pull request.

nodejs/node#13483

@unipheas
Copy link

unipheas commented Jun 8, 2017

Thanks!

@Bizarrus
Copy link

Bizarrus commented Jun 9, 2017

Same Issue here with node.js v8

@abenhamdine
Copy link

@Bizarrus Have you only checked nodejs/node#13483 and tried to install node 8.1.0 ?
And 'node.js v8' matches no existing version, it's either 8.0.0 or 8.1.0.

@soyuka
Copy link
Contributor

soyuka commented Jun 16, 2017

Is resolved on node 8.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests