Skip to content

Cancel active ZIP entries when the archive is destroyed - #228

Open
Sinkleberg wants to merge 1 commit into
archiverjs:masterfrom
Sinkleberg:codex/zip-destroy-cleanup
Open

Sinkleberg wants to merge 1 commit into
archiverjs:masterfrom
Sinkleberg:codex/zip-destroy-cleanup

Conversation

@Sinkleberg

Copy link
Copy Markdown

Destroying a ZIP archive now cancels its active input and compression stream and settles the entry callback once. Cancellation stays active through header and data-descriptor writes, preserving supplied errors and preventing later entry writes. Pending callbacks receive ERR_STREAM_DESTROYED when destruction has no error.

The library keeps its own source error handler until the input closes, so asynchronous cleanup failures cannot become unhandled errors after cancellation or successful completion. It preserves caller listeners and removes only its own handlers after close.

Fixes #143, covering the compress-commons part of archiverjs/node-zip-stream#166 and archiverjs/node-zip-stream#167.

Windows/Node 24.19.0: 25 cancellation checks fail against original production; the patched full Mocha suite passes 75 tests with 20 existing pending tests. Native subprocess probes cover failing cleanup with/without caller handlers, stored/deflated inputs and error/no-error cancellation. Complete-archive content and small ZIP64 descriptor controls pass, as does changed-file Prettier. The actual Mocha entry point was used because the Windows npm wrapper could not locate Mocha; Node 18/20 Linux CI and downstream integration were not run.

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

Successfully merging this pull request may close these issues.

Errors caused by destroying a stream

1 participant