Skip to content

stream: throw invalid argument errors - #31831

Closed
ronag wants to merge 4 commits into
nodejs:masterfrom
nxtedition:stream-throw-logic-error
Closed

ronag wants to merge 4 commits into
nodejs:masterfrom
nxtedition:stream-throw-logic-error

Conversation

@ronag

@ronag ronag commented Feb 17, 2020 •

Copy link
Copy Markdown
Member

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 Node.js streams. semver-major PRs that contain breaking changes and should be released in the next major version. labels Feb 17, 2020
@ronag
ronag requested review from lpinca and mcollina February 17, 2020 17:02
@ronag
ronag force-pushed the stream-throw-logic-error branch from 92ac737 to 36172d3 Compare February 17, 2020 17:02
@ronag

ronag commented Feb 17, 2020 •

Copy link
Copy Markdown
Member Author

@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 done
@ronag
ronag force-pushed the stream-throw-logic-error branch 2 times, most recently from 75f4dd3 to f334f94 Compare February 17, 2020 17:07
Comment thread lib/_stream_writable.js Outdated
Comment thread lib/_stream_writable.js Outdated
@ronag
ronag requested a review from mscdex February 17, 2020 17:13
Comment thread test/parallel/test-stream-writable-null.js Outdated
Comment thread lib/_stream_writable.js Outdated
Comment thread lib/_stream_writable.js Outdated
Comment thread lib/_stream_writable.js Outdated
Logic errors that do not depend on stream
state should throw instead of invoke callback
and emit error.
@ronag
ronag force-pushed the stream-throw-logic-error branch from 9f2b5ec to 722975a Compare February 17, 2020 20:25
@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

ronag commented Feb 17, 2020 •

Copy link
Copy Markdown
Member Author

@lpinca: Updated per our discussion

Comment thread test/parallel/test-stream-writable-invalid-chunk.js

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

attention here

@ronag
ronag force-pushed the stream-throw-logic-error branch from abecd9f to 93c4107 Compare February 17, 2020 22:58
gunzip.on('error', common.expectsError({
name: 'TypeError'
}));
});

Copy link
Copy Markdown
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
Copy Markdown
Collaborator

@ronag ronag added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Feb 18, 2020
@ronag
ronag requested a review from lpinca February 18, 2020 18:34
Comment thread test/parallel/test-zlib-invalid-input.js Outdated
Comment thread test/parallel/test-zlib-object-write.js Outdated

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@ronag

ronag commented Feb 18, 2020

Copy link
Copy Markdown
Member Author

needs another TSC approval, @addaleax @jasnell

@ronag

ronag commented Feb 18, 2020 •

Copy link
Copy Markdown
Member Author

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@ronag

ronag commented Feb 19, 2020

Copy link
Copy Markdown
Member Author

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 with CI started, the required approvals, and no outstanding review comments. label Feb 19, 2020
@ronag

ronag commented Feb 23, 2020

Copy link
Copy Markdown
Member Author

@ronag

ronag commented Feb 24, 2020

Copy link
Copy Markdown
Member Author

CITGM failures does not seem related to this PR.

@ronag ronag added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Feb 24, 2020
@ronag

ronag commented Feb 24, 2020

Copy link
Copy Markdown
Member Author

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

@ronag

ronag commented Feb 24, 2020

Copy link
Copy Markdown
Member Author

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

@Trott

Trott commented Feb 24, 2020

Copy link
Copy Markdown
Member

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

Trott commented Feb 24, 2020

Copy link
Copy Markdown
Member

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

Trott commented Feb 24, 2020

Copy link
Copy Markdown
Member

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 <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@ronag

ronag commented Feb 25, 2020

Copy link
Copy Markdown
Member Author

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 with CI started, the required approvals, and no outstanding review comments. semver-major PRs that contain breaking changes and should be released in the next major version. stream Issues and PRs related to Node.js streams.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants