Skip to content

zlib: BrotliCompress.flush() with Z_FINISH or Z_BLOCK hangs at 100% CPU #63701

@alii

Description

@alii

Version

v26.3.0 (also reproduces on v22.20.0 and v27.0.0-nightly20260601aa444b2f58)

Platform

Darwin arm64 but not platform-specific

Subsystem

zlib

What steps will reproduce the bug?

const zlib = require("zlib");
zlib.createBrotliCompress().flush(zlib.constants.Z_FINISH);

The process spins at ~100% CPU and never exits

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

Every time. flush(Z_FINISH) (4) and flush(Z_BLOCK) (5) both hang. flush(Z_TREES) (6) throws, and 0–3 are the valid brotli operations.

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

It should throw (as flush(6) already does) or be a no-op, not loop forever. Z_FINISH and Z_BLOCK are zlib flush modes with no corresponding brotli operation, so they reach a state the flush loop never satisfies.

What do you see instead?

The call never returns. CPU stays pinned and the event loop makes no progress. Calling .end() afterwards does not drain it.

Additional information

No response

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