archiverjs / node-archiver

a streaming interface for archive generation
https://www.archiverjs.com
MIT License
2.76k stars 218 forks source link

`append()` fails after upgrading from v6 to v7 #742

Closed soulchild closed 4 months ago

soulchild commented 4 months ago

Since upgrading from archiver@6 to archiver@7, my application fails with the following error:

ArchiverError: input source must be valid Stream or Buffer instance

I'm basically creating a zip of zips. Here's a minimal reproduction of the issue:

import archiver from 'archiver';
import { randomUUID } from 'node:crypto';

const createZip = (files) => {
  const archive = archiver('zip');
  for (const file of files) {
    archive.append(file, { name: randomUUID() });
  }
  archive.finalize();
  return archive;
};

const zip = createZip(['foobar']);
createZip([zip]);

I don't see anything listed in the CHANGELOG about there being a breaking change, so maybe one of the upgraded transient dependencies is the culprit?

Thanks for any hints!

ctalkington commented 4 months ago

the major change was node 12 support dropped across archiver repos which did include version bumps of dependencies like readable-stream.

I know we have tests for appending streams but not sure I've tried to pass archiver stream in this way.

ctalkington commented 4 months ago

it does look like archiver-utils has stream detection issues with newer readable-stream v4 as shown with a failing test here:

https://github.com/archiverjs/archiver-utils/pull/149

ctalkington commented 4 months ago

should be resolved (additional test added across repos) in next point release

soulchild commented 4 months ago

Awesome, @ctalkington! Thanks for the quick fix. I'll let you know if there's still a problem after upgrading to the next release.