npm @zip.js/zip.js 2.13.0

latest releases: 2.24.0, 2.23.0, 2.22.1...
one month ago

What's Changed in v2.13.0

Breaking changes

  • A stream cancelled or aborted while an entry is written or read now rejects with the reason the caller passed, whatever that reason is. It used to be replaced by TypeError: Cannot read properties of undefined (reading 'outputSize') when the reason was undefined, which is what cancelling a download produces, and by a comparable TypeError for a string, a number, null, or a frozen error. Code that matched on that TypeError has to match on the reason instead
  • ZipWriter#close() now reports an entry that failed with a falsy reason instead of returning the archive. Such a failure was read as "no failure", so the call returned a truncated archive and threw nothing
  • An archive written after an entry failed mid-write now records the entries added afterwards at the right offsets whatever the failure reason. They used to be recorded short by the number of bytes the failed entry had already written, which produced an archive a strict reader rejects, again with nothing thrown

Bug fixes

  • A rejection reason that cannot carry the outputSize annotation no longer fails while being annotated. That covers a reason which is not an object and an error which is frozen, sealed, or already carries a read-only outputSize. With a web worker the annotation threw before the promise was rejected, so the entry never settled at all and terminateWorkers() hung with it
  • A rejection reason crossing a codec worker now keeps its class and its value: a DOMException comes back as a DOMException with its name and its code, and a reason that is not an object comes back identical. Both used to be rebuilt from serialized fields as a plain Error, and undefined came back as Error: Unknown error
  • The number of bytes a failed entry had written now reaches the writer without passing through the rejection reason, so the offsets of the entries added afterwards no longer depend on that reason being an object that accepts a new property

Documentation

  • EntryError#outputSize no longer states that zip.js reads it to keep the offsets of later entries correct, which stopped being true once the size stopped travelling on the error. It documents instead that the property is absent when the reason cannot carry it, and that the salvage described on ZipWriter#close() does not depend on it
  • EntryError#corruptedEntry documents the same absence, and points at ZipWriter#hasCorruptedEntries, which reports the same thing on the writer and is always set

Tests and continuous integration

  • New test covering rejection reasons that are not errors, across the writer, the reader and close(), including reasons that are falsy, primitive, frozen, sealed, or already carrying a read-only outputSize
  • The audit of the property names crossing a worker message no longer descends into the caller's rejection reason, whose own property names come from user code and from the engine: a Firefox error carries fileName, lineNumber and columnNumber, and a Safari one carries line, column and sourceURL
  • The browser profile cleanup retries on Windows, where the browser can still hold a file of the profile for a moment after quitting. An EBUSY while deleting a temporary directory used to fail a run whose tests had all passed

Full Changelog: v2.12.0...v2.13.0

Don't miss a new zip.js release

NewReleases is sending notifications on new releases.