Skip to content

node:zlib: implement Zstd codecs beyond export shapes #2510

@andrewtdiz

Description

@andrewtdiz

Summary

Most of Perry's node:zlib surface has been filled in, but the Node 22+ Zstd APIs are currently only exposed as shapes. The ZstdCompress / ZstdDecompress classes and createZstd* factory names exist for typeof checks, but there is no runtime codec implementation or native-table dispatch for Zstd compression/decompression.

Evidence

  • test-files/test_parity_zlib.ts still probes zlib.ZstdCompress, zlib.ZstdDecompress, createZstdCompress, createZstdDecompress, zstdCompressSync, zstdDecompressSync, zstdCompress, and zstdDecompress.
  • crates/perry-api-manifest/src/entries.rs registers class("zlib", "ZstdCompress"), class("zlib", "ZstdDecompress"), zlib_stream_factory("createZstdCompress"), and zlib_stream_factory("createZstdDecompress"), but there are no zstdCompress, zstdDecompress, zstdCompressSync, or zstdDecompressSync manifest entries.
  • crates/perry-runtime/src/object/native_module.rs lists ZstdCompress, ZstdDecompress, createZstdCompress, and createZstdDecompress in the callable export whitelist, which makes property reads look function-shaped.
  • crates/perry-codegen/src/lower_call/native_table/media.rs has runtime rows for createGzip, createGunzip, createDeflate, createInflate, raw variants, createUnzip, and Brotli factories, but no createZstdCompress or createZstdDecompress rows.
  • crates/perry-stdlib/src/zlib.rs has stream codecs for gzip/gunzip/deflate/inflate/raw/unzip/Brotli, but no Codec::Zstd*, no js_zlib_create_zstd_*, and no one-shot Zstd functions.
  • Existing merged PRs have covered zlib constructor exports, constants, stream close/property shape, and stream instances, but not Zstd behavior.

I did not run a fresh local parity command because this checkout does not have a target/release/perry binary; this issue is based on committed parity metadata and source inspection.

Non-duplicates checked

Searches for node:zlib, zlib Zstd createZstd, zlib zstd, and PRs for zlib zstd found merged zlib work (#1927, #2257, #2260, #2265, #955), but no open or closed issue tracking actual Zstd codec behavior.

Expected behavior

Add Node-compatible Zstd support for the modern zlib surface:

  • zlib.zstdCompress(buffer[, options], callback)
  • zlib.zstdCompressSync(buffer[, options])
  • zlib.zstdDecompress(buffer[, options], callback)
  • zlib.zstdDecompressSync(buffer[, options])
  • zlib.createZstdCompress([options]) and zlib.createZstdDecompress([options]) as real transform-stream handles
  • ZstdCompress / ZstdDecompress constructors that match the surrounding zlib class export behavior

A first implementation can follow the existing zlib stream-handle pattern and add deterministic round-trip parity tests similar to the gzip/raw/Brotli suites.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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