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 wasundefined, which is what cancelling a download produces, and by a comparableTypeErrorfor a string, a number,null, or a frozen error. Code that matched on thatTypeErrorhas 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
outputSizeannotation 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-onlyoutputSize. With a web worker the annotation threw before the promise was rejected, so the entry never settled at all andterminateWorkers()hung with it - A rejection reason crossing a codec worker now keeps its class and its value: a
DOMExceptioncomes back as aDOMExceptionwith itsnameand itscode, and a reason that is not an object comes back identical. Both used to be rebuilt from serialized fields as a plainError, andundefinedcame back asError: 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#outputSizeno 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 onZipWriter#close()does not depend on itEntryError#corruptedEntrydocuments the same absence, and points atZipWriter#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-onlyoutputSize - 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,lineNumberandcolumnNumber, and a Safari one carriesline,columnandsourceURL - The browser profile cleanup retries on Windows, where the browser can still hold a file of the profile for a moment after quitting. An
EBUSYwhile deleting a temporary directory used to fail a run whose tests had all passed
Full Changelog: v2.12.0...v2.13.0