Skip to content

Zip.append callback is not invoked. #385

@tom-marsh

Description

@tom-marsh

The documentation for the Zip.append method states that it takes a callback function, however the callback function is never actually called.

Minimal example:

"use strict";

const archiver = require("archiver");
const Writable = require("stream").Writable;

const archive = archiver("zip", {
    zlib: {
        level: 9
    }
});

archive.pipe(new Writable({
    write(chunk, encoding, callback) {
        console.log("Processing:", chunk);
        callback();
    }
}));

archive.append("abc", {
    name: "abc.txt"
}, () => {
    // Never logged.
    console.log("Done.");
});

archive.finalize();

Looking at the source code, the append method in lib/plugins/zip.js has a callback function, which seems to be provided by _moduleAppend in lib/core.js, rather than by the user.

The desired use case was wrapping the archiver in a Node writable stream as the final step in a stream processing pipeline for exporting data, for which callbacks are a cleaner interface to manage backpressure than events.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions