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

stream: throw invalid argument errors #31831

Closed
wants to merge 4 commits into from

Conversation

ronag
Copy link
Member

@ronag ronag commented Feb 17, 2020

Logic errors that do not depend on stream state should throw instead of invoke callback and emit error.

Refs: #31818

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. semver-major PRs that contain breaking changes and should be released in the next major version. labels Feb 17, 2020
@ronag
Copy link
Member Author

ronag commented Feb 17, 2020

@mcollina: Has a comment which I don't understand:

In the current world of async/await, all errors are automatically catched and go to unhandledRejection :/. Essentially, we need to make sure that the stream is properly destroyed if it happens.

@ronag ronag mentioned this pull request Feb 17, 2020
4 tasks
@ronag ronag force-pushed the stream-throw-logic-error branch 2 times, most recently from 75f4dd3 to f334f94 Compare February 17, 2020 17:07
lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
@ronag ronag requested a review from mscdex February 17, 2020 17:13
lib/_stream_writable.js Outdated Show resolved Hide resolved
Logic errors that do not depend on stream
state should throw instead of invoke callback
and emit error.
@ronag ronag changed the title stream: throw on logic errors stream: throw invalid argument errors Feb 17, 2020
@ronag ronag requested a review from lpinca February 17, 2020 20:25
@ronag
Copy link
Member Author

ronag commented Feb 17, 2020

@lpinca: Updated per our discussion

assert.throws(() => {
zlib.gunzip(input);
}, {
name: 'TypeError'
});
Copy link
Member Author

Choose a reason for hiding this comment

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

attention here

gunzip.on('error', common.expectsError({
name: 'TypeError'
}));
});
Copy link
Member Author

Choose a reason for hiding this comment

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

attention here

@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 Feb 18, 2020
@ronag ronag requested a review from lpinca February 18, 2020 18:34
test/parallel/test-zlib-invalid-input.js Outdated Show resolved Hide resolved
test/parallel/test-zlib-object-write.js Outdated 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

Co-Authored-By: Luigi Pinca <luigipinca@gmail.com>
@ronag
Copy link
Member Author

ronag commented Feb 18, 2020

needs another TSC approval, @addaleax @jasnell

@ronag
Copy link
Member Author

ronag commented Feb 18, 2020

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

@ronag
Copy link
Member Author

ronag commented Feb 19, 2020

eslint-jest fails in CITGM:

 Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main resolved in /home/iojs/tmp/citgm_tmp/c642c97c-de5a-4bd0-8352-67943d3c1070/eslint-plugin-jest/node_modules/@babel/helper-compilation-targets/package.json
     at applyExports (internal/modules/cjs/loader.js:528:9)
     at resolveExports (internal/modules/cjs/loader.js:545:12)
     at Function.Module._findPath (internal/modules/cjs/loader.js:666:22)
     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1020:27)
     at Function.Module._load (internal/modules/cjs/loader.js:909:27)
     at Module.require (internal/modules/cjs/loader.js:1093:19)
     at require (internal/modules/cjs/helpers.js:72:18)
     at Object.<anonymous> (/home/iojs/tmp/citgm_tmp/c642c97c-de5a-4bd0-8352-67943d3c1070/eslint-plugin-jest/node_modules/@babel/preset-env/lib/debug.js:8:33)
     at Module._compile (internal/modules/cjs/loader.js:1204:30)
     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1224:10) {
   code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
 }

@ronag ronag removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 19, 2020
@ronag
Copy link
Member Author

ronag commented Feb 23, 2020

@ronag
Copy link
Member Author

ronag commented Feb 24, 2020

CITGM failures does not seem related to this PR.

@ronag ronag added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 24, 2020
@ronag
Copy link
Member Author

ronag commented Feb 24, 2020

CITGM (master) for comparison: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/2281/

@ronag
Copy link
Member Author

ronag commented Feb 24, 2020

I think this can land given that the CITGM failures seems unrelated. @Trott I'd appreciate a second opinion before landing.

@Trott
Copy link
Member

Trott commented Feb 24, 2020

I think this can land given that the CITGM failures seems unrelated. @Trott I'd appreciate a second opinion before landing.

Yes, I'd agree. Thanks for opening nodejs/citgm#785.

@Trott
Copy link
Member

Trott commented Feb 24, 2020

I think this can land given that the CITGM failures seems unrelated. @Trott I'd appreciate a second opinion before landing.

Yes, I'd agree. Thanks for opening nodejs/citgm#785.

Oh, wait, I agree that CITGM is not an obstacle. But it does still need a second TSC approval because it's semver-major. @nodejs/tsc

@Trott
Copy link
Member

Trott commented Feb 24, 2020

Oh, wait, I agree that CITGM is not an obstacle. But it does still need a second TSC approval because it's semver-major.

Looks good to me and I've added my approval, so this can land. Might not be a bad idea to leave it open for 24 hours or so just to give people one more chance to take a look, but that's not strictly required.

ronag added a commit that referenced this pull request Feb 25, 2020
Logic errors that do not depend on stream
state should throw instead of invoke callback
and emit error.

PR-URL: #31831
Refs: #31818
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@ronag
Copy link
Member Author

ronag commented Feb 25, 2020

Landed in 1f20912

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants