Skip to content

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Aug 9, 2025

Summary by CodeRabbit

  • Chores

    • Updated .gitignore to exclude pnpm-lock.yaml from version control.
    • Updated GitHub Actions workflows with a new merge group trigger and revised release job configuration.
  • Refactor

    • Improved ZIP file uncompression with enhanced error handling and centralized completion callbacks.
    • Added debug logging to improve traceability during ZIP extraction.
  • Style

    • Suppressed console log outputs in multiple test suites for cleaner test execution.

@fengmk2 fengmk2 requested a review from Copilot August 9, 2025 08:43
@coderabbitai
Copy link

coderabbitai bot commented Aug 9, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The .gitignore file was updated to ignore pnpm-lock.yaml. The ZipUncompressStream class in lib/zip/uncompress_stream.js was refactored to centralize error and finish handling through a new _finalCallback, add debug logging, and update stream method signatures and logic. A new test was added to verify error handling for non-zip files. GitHub Actions workflows were modified to add a new event trigger and update the release job configuration, including changing the reusable workflow and adjusting secrets. Multiple test files had console.log statements commented out to reduce test output noise.

Changes

Cohort / File(s) Change Summary
Gitignore Update
.gitignore
Added pnpm-lock.yaml to the list of ignored files.
ZipUncompressStream Refactor
lib/zip/uncompress_stream.js
Refactored stream logic: introduced _finalCallback for centralized error/finish signaling, added debug logging, updated _write method signature to standard stream form, added _final method, and changed error handling to invoke the callback instead of emitting events. Streamlined control flow and improved traceability.
ZipUncompressStream Tests
test/zip/uncompress_stream.test.js
Added a new async test to verify that UncompressStream throws an error when uncompressing a non-zip file (e.g., .tgz). Also added a blank line after a directory creation call for readability.
GitHub Actions Workflow Updates
.github/workflows/nodejs.yml, .github/workflows/release.yml
Added merge_group event trigger to nodejs.yml. Modified release.yml to rename job from "Node.js" to "NPM", switch reusable workflow from node-release.yml to npm-release.yml, and removed NPM_TOKEN secret, leaving only GIT_TOKEN.
Test Console Output Suppression
test/gzip/*, test/tar/*, test/tgz/*, test/zip/*
Commented out numerous console.log statements printing destination file paths and error objects across multiple test files to reduce noisy output during test runs. No logic or assertions were changed.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ZipUncompressStream
    participant yauzl

    User->>ZipUncompressStream: write(chunk)
    ZipUncompressStream->>ZipUncompressStream: _write(chunk, _encoding, callback)
    ZipUncompressStream->>User: callback()

    User->>ZipUncompressStream: end()
    ZipUncompressStream->>ZipUncompressStream: _final(callback)
    ZipUncompressStream->>yauzl: fromBuffer(buffer, options, [YAUZL_CALLBACK])
    yauzl-->>ZipUncompressStream: (err, zipFile)
    alt err
        ZipUncompressStream->>User: _finalCallback(err)
    else success
        ZipUncompressStream->>User: _finalCallback(null)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

A lock file now ignored,
Streams refactored, errors stored—
Debug logs hop in with glee,
Central callbacks set us free.
Workflows tuned, secrets trimmed tight,
Tests polished, all feels right!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @fengmk2, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This PR refactors the ZipUncompressStream to correctly handle stream termination and error propagation by implementing the _final method. This change replaces a less robust approach that relied on the pipe event, leading to more reliable and standard stream behavior for uncompressing zip files.

Highlights

  • Stream Refactoring: Replaced the custom pipe event handling logic in ZipUncompressStream with a standard Node.js _final method implementation for proper stream termination.
  • Error and Completion Handling: Centralized error and stream completion callbacks within ZipUncompressStream to ensure consistent behavior, especially when dealing with yauzl events.
  • Debugging Improvements: Integrated util.debuglog for enhanced debugging capabilities within the ZipUncompressStream, providing better visibility into stream operations.
  • Build Configuration: Updated .gitignore to include pnpm-lock.yaml, reflecting changes in dependency management practices.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the ZIP uncompression stream implementation to use the proper Node.js stream _final method instead of a hacky pipe event listener. The change improves the stream's lifecycle management by implementing the standard writable stream interface.

  • Replaces pipe event hack with proper _final method implementation
  • Adds debug logging throughout the uncompression process
  • Updates error handling to use callback-based approach consistent with stream patterns

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
lib/zip/uncompress_stream.js Main refactoring to implement _final method and replace pipe event handling with proper stream lifecycle
test/zip/uncompress_stream.test.js Minor formatting change (blank line addition)

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the ZipUncompressStream to correctly implement the Node.js Writable stream interface by using _write and _final methods. This replaces a previous implementation that relied on a 'pipe' event listener hack. The changes make the stream handling more robust and idiomatic. My review includes one suggestion to remove a stale comment that is no longer valid after this refactoring.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
lib/zip/uncompress_stream.js (2)

42-48: _finalCallback overwritten later – can lose debug/error emit wrapper.
When _final runs it replaces _finalCallback with the raw callback, so subsequent errors (e.g. openReadStream failure) skip the debug log and emit path defined here.
Wrap the stream’s callback instead of wholesale replacing the property to keep consistent logging/emission behaviour.


74-80: Possible back-pressure / type-safety issue in _write.
callback() is invoked immediately after buffering; large archives will still accumulate unbounded RAM, but at least honour stream.Writable back-pressure by waiting for high-water-mark drain signals (defer callback until this.push equivalent).
debug('write size: %d', chunk.length) assumes chunk is a Buffer; if a string is written the %d formatter will coerce incorrectly.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ac1164 and 0f89eac.

📒 Files selected for processing (3)
  • .gitignore (1 hunks)
  • lib/zip/uncompress_stream.js (4 hunks)
  • test/zip/uncompress_stream.test.js (1 hunks)
🔇 Additional comments (3)
.gitignore (1)

10-10: Ignore entry looks good.
Adding pnpm-lock.yaml is a harmless housekeeping update.

test/zip/uncompress_stream.test.js (1)

24-24: No behavioural change detected.
Blank-line addition is purely cosmetic – nothing further.

lib/zip/uncompress_stream.js (1)

81-86: Guard empty-input for piped usage.
If nothing was written before end(), Buffer.concat([]) yields an empty buffer and yauzl.fromBuffer will synchronously error. Detect empty buffer and fail fast with a clear message.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
.github/workflows/release.yml (1)

9-13: Add back the NPM_TOKEN secret so npm publish can authenticate

Without explicitly passing NPM_TOKEN into the reusable workflow, semantic-release will not have the credentials needed to publish to npm and will fail.

Please update .github/workflows/release.yml to include:

 jobs:
   release:
     name: NPM
     uses: node-modules/github-actions/.github/workflows/npm-release.yml@master
     secrets:
       GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
+      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
🧹 Nitpick comments (1)
.github/workflows/nodejs.yml (1)

3-11: Optional: add concurrency to reduce duplicate CI runs across push/pull_request/merge_group.

Helps cancel superseded runs on the same ref.

Apply:

 name: CI

 on:
   push:
     branches: [ master ]

   pull_request:
     branches: [ master ]

   merge_group:

+concurrency:
+  group: ci-${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f89eac and fe7f072.

📒 Files selected for processing (2)
  • .github/workflows/nodejs.yml (1 hunks)
  • .github/workflows/release.yml (1 hunks)
🔇 Additional comments (3)
.github/workflows/nodejs.yml (2)

10-11: Addition of merge_group trigger: LGTM.

This correctly enables runs from GitHub’s merge queue. Ensure merge queue is enabled on the repo/org; otherwise this event won’t fire.


18-18: Node.js 24 is supported by the reusable workflow

The version input is treated as a free-form string and converted to a matrix by action_repo/scripts/test/index.js, with no hard-coded whitelist. In the Test job we use actions/setup-node@v4 with check-latest: true, so any valid Node.js release—including 24—will be fetched even if it’s not preinstalled on runners.

No further changes needed.

.github/workflows/release.yml (1)

9-10: Reusable npm-release workflow path verified

The referenced workflow at node-modules/github-actions/.github/workflows/npm-release.yml@master exists and is publicly accessible. No further action is needed.

@codecov
Copy link

codecov bot commented Aug 9, 2025

Codecov Report

❌ Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.99%. Comparing base (8e5f04a) to head (d688a0b).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
lib/zip/uncompress_stream.js 90.32% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #114      +/-   ##
==========================================
+ Coverage   97.76%   97.99%   +0.23%     
==========================================
  Files          19       19              
  Lines        1028     1048      +20     
  Branches      273      277       +4     
==========================================
+ Hits         1005     1027      +22     
+ Misses         23       21       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
test/zip/index.test.js (1)

29-29: Prefer removing commented-out code or using a toggleable debug helper

Leaving commented-out logs around causes drift. Either remove them entirely or switch to a conditional debug helper so you can enable logs locally without code changes.

Option A — remove the dead lines:

-      // console.log('dest', destFile);
-      // console.log('dest', destFile);
-      // console.log('dest', destFile);
-      // console.log('dest', destFile);
-      // console.log('dest', destFile);
-      // console.log('dest', destFile);
-      // console.log('dest', destFile);
-      // console.log('dest', destFile);
-    // console.log('dest', destFile);
-    // console.log(destDir);

Option B — keep them but behind a debug helper:

-      // console.log('dest', destFile);
+      debug('dest', destFile);
-      // console.log('dest', destFile);
+      debug('dest', destFile);
-      // console.log('dest', destFile);
+      debug('dest', destFile);
-      // console.log('dest', destFile);
+      debug('dest', destFile);
-      // console.log('dest', destFile);
+      debug('dest', destFile);
-      // console.log('dest', destFile);
+      debug('dest', destFile);
-      // console.log('dest', destFile);
+      debug('dest', destFile);
-      // console.log('dest', destFile);
+      debug('dest', destFile);
-    // console.log('dest', destFile);
+    debug('dest', destFile);
-    // console.log(destDir);
+    debug(destDir);

Add this small helper near the top of the file (or import from a shared test util):

// test/util/debug.js (recommended) or inline in this file
const DEBUG = process.env.TEST_DEBUG === '1';
function debug(...args) {
  if (DEBUG) console.log(...args);
}

Also applies to: 40-40, 73-73, 85-85, 98-98, 109-109, 120-120, 130-130, 282-282, 293-293

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc3712c and d688a0b.

📒 Files selected for processing (12)
  • test/gzip/file_stream.test.js (4 hunks)
  • test/gzip/index.test.js (3 hunks)
  • test/tar/file_stream.test.js (2 hunks)
  • test/tar/index.test.js (12 hunks)
  • test/tar/stream.test.js (10 hunks)
  • test/tgz/file_stream.test.js (1 hunks)
  • test/tgz/index.test.js (8 hunks)
  • test/tgz/stream.test.js (10 hunks)
  • test/zip/file_stream.test.js (1 hunks)
  • test/zip/index.test.js (10 hunks)
  • test/zip/stream.test.js (10 hunks)
  • test/zip/uncompress_stream.test.js (2 hunks)
✅ Files skipped from review due to trivial changes (10)
  • test/zip/file_stream.test.js
  • test/tgz/file_stream.test.js
  • test/gzip/file_stream.test.js
  • test/tar/file_stream.test.js
  • test/gzip/index.test.js
  • test/tar/stream.test.js
  • test/tgz/stream.test.js
  • test/tar/index.test.js
  • test/tgz/index.test.js
  • test/zip/stream.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/zip/uncompress_stream.test.js
🔇 Additional comments (1)
test/zip/index.test.js (1)

29-29: Silencing noisy test logs is a good cleanup

Commenting out these console logs keeps CI output clean and focused on failures. Looks good.

Also applies to: 40-40, 73-73, 85-85, 98-98, 109-109, 120-120, 130-130, 282-282, 293-293

@fengmk2 fengmk2 merged commit ba52b7b into master Aug 9, 2025
17 of 18 checks passed
@fengmk2 fengmk2 deleted the fix-tests branch August 9, 2025 11:50
fengmk2 pushed a commit that referenced this pull request Aug 9, 2025
[skip ci]

## 2.0.0 (2025-08-09)

* fix: impl _final method instead hack pipe event (#114) ([ba52b7b](ba52b7b)), closes [#114](#114)
* feat: remove `pump` and raise minimum node to v18 (#113) ([8ac1164](8ac1164)), closes [#113](#113)

### BREAKING CHANGE

* Drop Node.js < 18 support

Node.js 4 is long EOL, so this PR raises it to 18 as per comment. Node
10 has built-in `stream.pipeline` and `fs.mkdir` with `recursive`
option, which can be used instead of `pump` (they are the same).

Also 3 tests fail for me but they fail on main branch as well (timeout)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Replaced the external stream piping utility with the native Node.js
stream API throughout the codebase and tests.
* Updated documentation examples to reflect the new usage of the native
stream API.
* Replaced external directory creation utilities with native Node.js
directory creation methods using recursive options.
* Removed obsolete dependencies and increased the minimum required
Node.js version to 18.0.0.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@github-actions
Copy link

github-actions bot commented Aug 9, 2025

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants