Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zlib: align with streams #32220

Closed
wants to merge 3 commits into from
Closed

Conversation

ronag
Copy link
Member

@ronag ronag commented Mar 12, 2020

  • Ensure automatic destruction only happens after both
    'end' and 'finish' has been emitted through autoDestroy.
  • Ensure close() callback is always invoked.
  • Ensure 'error' is only emitted once.
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@ronag ronag added stream Issues and PRs related to the stream subsystem. zlib Issues and PRs related to the zlib subsystem. labels Mar 12, 2020
@ronag ronag requested a review from addaleax March 12, 2020 07:20
- Ensure automatic destruction only happens after both
'end' and 'finish' has been emitted through autoDestroy.
- Ensure close() callback is always invoked.
- Ensure 'error' is only emitted once.
@@ -260,8 +263,7 @@ function ZlibBase(opts, mode, handle, { flush, finishFlush, fullFlush }) {
}
}

Transform.call(this, { autoDestroy: false, ...opts });
this._hadError = false;
Copy link
Member Author

Choose a reason for hiding this comment

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

We could keep _hadError for compat if necessary.

@ronag ronag requested a review from lpinca March 13, 2020 09:24
@ronag
Copy link
Member Author

ronag commented Mar 13, 2020

@nodejs/zlib

@ronag ronag requested a review from mcollina March 13, 2020 09:25
lib/zlib.js Outdated Show resolved Hide resolved
lib/zlib.js Outdated Show resolved Hide resolved
@BridgeAR
Copy link
Member

It would be good to get another review. I would like to get this into the next v13.x release, if this is ready.

@nodejs-github-bot
Copy link
Collaborator

@ronag ronag added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 19, 2020
lib/zlib.js Show resolved Hide resolved
lib/zlib.js Show resolved Hide resolved
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@nodejs-github-bot
Copy link
Collaborator

@ronag
Copy link
Member Author

ronag commented Mar 19, 2020

Landed in a940143

@ronag ronag closed this Mar 19, 2020
ronag added a commit that referenced this pull request Mar 19, 2020
- Ensure automatic destruction only happens after both
'end' and 'finish' has been emitted through autoDestroy.
- Ensure close() callback is always invoked.
- Ensure 'error' is only emitted once.

PR-URL: #32220
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@ronag
Copy link
Member Author

ronag commented Mar 19, 2020

FYI @BridgeAR

@MylesBorins
Copy link
Contributor

Hey @ronag, this doesn't land cleanly on v13.x, should it be backported?

ronag added a commit to nxtedition/node that referenced this pull request Mar 19, 2020
- Ensure automatic destruction only happens after both
'end' and 'finish' has been emitted through autoDestroy.
- Ensure close() callback is always invoked.
- Ensure 'error' is only emitted once.

PR-URL: nodejs#32220
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Backport-PR-URL: nodejs#32371
@kevinoid
Copy link
Contributor

It appears that as a result of this PR, close passes ERR_STREAM_PREMATURE_CLOSE to its callback when closed before 'end'. For example:

const { Inflate } = require('zlib');
new Inflate().close(console.error);

Prints nothing in 543c046 and ERR_STREAM_PREMATURE_CLOSE in a940143 (and current master, 668bc11).

I don't know whether this is expected behavior and/or whether the docs should be clearer (either about when to call close or what errors to expect), but thought it was worth mentioning to be sure you are aware of the change.

@addaleax addaleax added semver-major PRs that contain breaking changes and should be released in the next major version. and removed backport-requested-v13.x labels Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. semver-major PRs that contain breaking changes and should be released in the next major version. stream Issues and PRs related to the stream subsystem. zlib Issues and PRs related to the zlib subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants