Skip to content

node:zlib: dictionary option is silently ignored by deflate/inflate #37035

Open

Description

@jpowersdev

Version: Deno 2.9.4 (aarch64-apple-darwin)

The dictionary option of node:zlib is silently ignored. Compressing with a dictionary produces byte-for-byte the same output as compressing without one, and inflating ignores the dictionary too, so streams compressed with a preset dictionary by Node (or any zlib) can't be decompressed in Deno. Applies to both raw (deflateRawSync/inflateRawSync) and zlib-wrapped (deflateSync) formats.

import zlib from "node:zlib";
const dictionary = Buffer.from("hello world hello world");
const input = Buffer.from("hello world");
const withDict = zlib.deflateRawSync(input, { dictionary });
const noDict = zlib.deflateRawSync(input);
console.log("with dictionary:", withDict.toString("hex"));
console.log("no dictionary:  ", noDict.toString("hex"));
console.log("identical:", withDict.equals(noDict));

// Output produced by Node for the same input + dictionary:
const fromNode = Buffer.from("43620200", "hex");
try {
  console.log("inflate Node output:", zlib.inflateRawSync(fromNode, { dictionary }).toString());
} catch (e) {
  console.log("inflate Node output threw:", e.message);
}

Node v24.18.1:

with dictionary: 43620200
no dictionary:   cb48cdc9c95728cf2fca490100
identical: false
inflate Node output: hello world

Deno 2.9.4:

with dictionary: cb48cdc9c95728cf2fca490100
no dictionary:   cb48cdc9c95728cf2fca490100
identical: true
inflate Node output threw: invalid distance too far back

Related: #29638 (closed node:zlib tracking issue).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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