Skip to content

πŸ› Bug Report β€” issue in workerd zlib implementationΒ #6286

@alexander-azizi-martin

Description

@alexander-azizi-martin

zlib.inflateRawSync throws Uncaught RangeError: Memory limit exceeded when maxOutputLength is set to exactly the expected inflated size of a zip file. Incrementing it by 1 resolves the issue.

Setup

wrangler.jsonc:

"rules": [
  {
    "type": "Data",
    "globs": ["**/*.zip"],
    "fallthrough": true,
  },
],

The following fails in a Cloudflare Worker with the error above:

import AdmZip from 'adm-zip';
import compressedData from './compressed.zip';

const zip = new AdmZip(compressedData);
const zipEntry = zip.getEntries()[0].getData();

adm-zip passes the exact expected size as maxOutputLength to zlib.inflateRawSync. The issue originates here and paching it to use expectedLength + 1 fixes the issue:

https://github.com/cthackers/adm-zip/blob/1cd32f7e0ad3c540142a76609bb538a5cda2292f/methods/inflater.js#L5

This seems to be a bug with the workerd implementation of zlib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions