Skip to content

zlib: avoid an extra empty zstd frame - #66161

Open
marcopiraccini wants to merge 1 commit into
nodejs:mainfrom
marcopiraccini:zstd-empty-frame
Open

marcopiraccini wants to merge 1 commit into
nodejs:mainfrom
marcopiraccini:zstd-empty-frame

Conversation

@marcopiraccini

@marcopiraccini marcopiraccini commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

createZstdCompress() could append an empty frame when end() was called while writes were still queued. The last queued chunk could finish the frame, then the stream's final flush sent ZSTD_e_end again with no input.

Track when the frame has ended and skip empty calls until more input arrives. This avoids the extra frame while still allowing a later write to start a new one.

Added test/parallel/test-zlib-zstd-compress-single-frame.js to cover queued writes, explicit frame endings, an empty flush, an empty stream, and a later frame.

Fixes: #66078

Note

PR #66091 proposed the same C++ fix but was closed without merging. This PR expands the regression coverage to include an empty flush after a completed frame, an empty stream, and a deliberate second frame, alongside queued writes and an explicit end flush. The empty flush completes before end() so the test exercises ZSTD_e_flush separately.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib module and its compression dependencies. labels Sep 20, 2026
@marcopiraccini
marcopiraccini marked this pull request as ready for review September 20, 2026 15:22
@codecov

codecov Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.35%. Comparing base (75e4bbe) to head (3833a92).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66161      +/-   ##
==========================================
- Coverage   90.36%   90.35%   -0.02%     
==========================================
  Files         792      792              
  Lines      275398   275430      +32     
  Branches    52776    52787      +11     
==========================================
- Hits       248877   248869       -8     
- Misses      16937    16984      +47     
+ Partials     9584     9577       -7     
Files with missing lines Coverage Δ
src/node_zlib.cc 80.30% <100.00%> (+0.08%) ⬆️

... and 37 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@meixg meixg added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 21, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 21, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@ShogunPanda ShogunPanda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@panva panva added author ready PRs with CI started, the required approvals, and no outstanding review comments. resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. labels Sep 25, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Sep 25, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@github-actions github-actions Bot removed the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts with its base branch, removing the author ready label.
Please rebase your branch onto the latest base branch, resolve the conflicts locally, and force-push.
Afterwards the pull request needs a fresh collaborator approval, and a collaborator will add the label back once it is author ready again.

Signed-off-by: marcopiraccini <marco.piraccini@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. zlib Issues and PRs related to the zlib module and its compression dependencies.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zlib: createZstdCompress appends an empty frame when end() is called with writes still queued

6 participants