Skip to content

unzipper 0.11.5 completely breaks reading of docx files #311

@jribbens

Description

@jribbens

Summary

unzipper 0.11.4 and earlier works fine for reading DOCX files (which are zip files). 0.11.5 however is completely broken and crashes with Error: FILE_ENDED.

Sample code

import { readFile } from 'node:fs/promises'
import * as unzipper from 'unzipper'
const ARCHIVE = 'example0.docx'
const FILENAME = 'word/_rels/document.xml.rels'
console.log('opening archive')
const archive = await unzipper.Open.buffer(await readFile(ARCHIVE))
console.log('finding file')
const file = archive.files.find(file => file.path === FILENAME)
console.log('reading file')
const contents = await file.buffer()
console.log('file length', contents.length)

Output under 0.11.4

opening archive
finding file
reading file
file length 817

Output under 0.11.5

opening archive
finding file
reading file
node:internal/process/esm_loader:97
    internalBinding('errors').triggerUncaughtException(
                              ^

Error: FILE_ENDED
    at PullStream.pull (/home/jon/src/unzipper-test/node_modules/unzipper/lib/PullStream.js:78:28)
    at PullStream.emit (node:events:514:28)
    at PullStream.<anonymous> (/home/jon/src/unzipper-test/node_modules/unzipper/lib/PullStream.js:15:10)
    at PullStream.emit (node:events:526:35)
    at finish (node:internal/streams/writable:748:10)
    at finishMaybe (node:internal/streams/writable:733:9)
    at afterWrite (node:internal/streams/writable:507:3)
    at onwrite (node:internal/streams/writable:480:7)
    at cb (/home/jon/src/unzipper-test/node_modules/unzipper/lib/PullStream.js:38:14)
    at /home/jon/src/unzipper-test/node_modules/unzipper/lib/PullStream.js:71:91
    at afterWrite (node:internal/streams/writable:500:5)
    at afterWriteTick (node:internal/streams/writable:487:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:81:21)

Node.js v18.17.1

Example input file

The example input file is downloadable here: https://unequivocal.eu/dl/example0.docx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions