gildas-lormeau/zip.js

RangeError [ERR_BUFFER_TOO_LARGE] occurs if the ZIP file contains a file larger than 4GB (ZIP64 format)

shuhei-tagawa opened this issue · 4 comments

Hi,

When attempting to read data from a ZIP file using entry.getData(writer), a RangeError [ERR_BUFFER_TOO_LARGE] occurs if the ZIP file contains a file larger than 4GB (ZIP64 format).
This leads to the termination of the Node.js process.

Is there any way to fix this issue?

const zipFilePath = "./sample.zip"
const buffer = fs.readFileSync(zipFilePath);
const compressed = new Blob([Buffer.from(buffer)], {
  type: "application/zip",
});
const binaryReader = new BlobReader(compressed);
const reader = new ZipReader(binaryReader);
const entries = await reader.getEntries();

for (const [index, entry] of entries.entries()) {
  const writer = new BlobWriter();
  await entry.getData(writer); // RangeError [ERR_BUFFER_TOO_LARGE]: Cannot create a Buffer larger than 4294967295 bytes
  const fileContent = await writer.getData();
}

What version of Node.js are you using?

Hi, It's v18.0.0.

I've tried to make own Writer class and pass it to getData() but It hasn't worked so far.

I think Node does not support Blobs larger than 4GB actually. Can you paste your Writer implementation?

I'm converting this issue to a discussion because it's related to a limitation of Node.js.