Skip to content

Zstd silently ignores an ArrayBuffer passed as the dictionary option #64598

Description

@islandryu

Version

26.5.0

Platform

Darwin 25.5.0 arm64

Subsystem

No response

What steps will reproduce the bug?

  const zlib = require('node:zlib');
  const dict = Buffer.from('the quick brown fox '.repeat(4));
  const ab = dict.buffer.slice(dict.byteOffset, dict.byteOffset + dict.byteLength);

  console.log(zlib.zstdCompressSync(dict, { dictionary: dict }).length);       // 16 (dict used)
  console.log(zlib.zstdCompressSync(dict, { dictionary: ab }).length);         // 63 (dict ignored)
  console.log(zlib.zstdCompressSync(dict).length);                            // 63 (no dict)
 

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

An ArrayBuffer dictionary is honored.
Both frames should be 16.

What do you see instead?

The ArrayBuffer is silently dropped and zstd compresses with no dictionary (63).

Additional information

According to the docs this may not be a bug(the Zstd dictionary option is documented as {Buffer} only).
But deflate/inflate and Brotli accept an ArrayBuffer, so it would be nice to align Zstd with them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions