Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
shuhei-tagawa opened this issue Jan 24, 2024 · 4 comments

Comments

@shuhei-tagawa
Copy link

shuhei-tagawa commented Jan 24, 2024

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();
}
@gildas-lormeau
Copy link
Owner

What version of Node.js are you using?

@shuhei-tagawa
Copy link
Author

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.

@gildas-lormeau
Copy link
Owner

gildas-lormeau commented Jan 27, 2024

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

@gildas-lormeau
Copy link
Owner

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

Repository owner locked and limited conversation to collaborators Jan 29, 2024
@gildas-lormeau gildas-lormeau converted this issue into discussion #481 Jan 29, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants