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: give error message if write() cb called twice #19510

Closed
wants to merge 3 commits into from

Conversation

addaleax
Copy link
Member

Otherwise, this condition would result in an error that just reads
cb is not a function, and which additionally could have lost
stack trace context through a process.nextTick() call.

$ ./node benchmark/compare.js --new ./node --old ./node-master --filter writable --runs 200 streams | Rscript benchmark/compare.R
[00:09:36|% 100| 1/1 files | 400/400 runs | 1/1 configs]: Done
                                           confidence improvement accuracy (*)   (**)  (***)
 streams/writable-manywrites.js n=2000000                -0.28 %       ±3.51% ±4.62% ±5.92%
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

Otherwise, this condition would result in an error that just reads
`cb is not a function`, and which additionally could have lost
stack trace context through a `process.nextTick()` call.

    $ ./node benchmark/compare.js --new ./node --old ./node-master --filter writable --runs 200 streams | Rscript benchmark/compare.R
    [00:09:36|% 100| 1/1 files | 400/400 runs | 1/1 configs]: Done
                                               confidence improvement accuracy (*)   (**)  (***)
     streams/writable-manywrites.js n=2000000                -0.28 %       ±3.51% ±4.62% ±5.92%
@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originated in Node.js core. stream Issues and PRs related to the stream subsystem. labels Mar 21, 2018
@addaleax
Copy link
Member Author

@nodejs/streams

Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

LGTM, but why not just reuse the existing ERR_MULTIPLE_CALLBACK error?

@lpinca
Copy link
Member

lpinca commented Mar 21, 2018

👍 to @cjihrig's suggestion.

@addaleax
Copy link
Member Author

Yeah, done. Just didn’t know that that existed. :)

@lpinca
Copy link
Member

lpinca commented Mar 21, 2018

@addaleax I think you forgot to remove ERR_STREAM_WRITE_CALLBACK_TWICE from lib/internal/errors.js in the latest commit.

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

@mcollina mcollina added the semver-major PRs that contain breaking changes and should be released in the next major version. label Mar 21, 2018
@mcollina
Copy link
Member

I flagged this as semver-major, mainly because it changes the error message and because it uses the new errors (which is semver-major for readable-stream).

@addaleax
Copy link
Member Author

I flagged this as semver-major, mainly because it changes the error message

I would respectfully disagree. As said in the commit message, the previous error message came from trying to call null as a function. That's a VM-generated message, and we haven't generally made guarantees about those.

But more importantly, there is no reason to ever test this error message. It's always a programming error, not some condition that could be detected at runtime.

and because it uses the new errors (which is semver-major for readable-stream).

Can you expand on that? We already use the new errors in the streams code, and it isn't obvious how readable-stream's semver levels relate to Node core's int hese situations_

@mcollina
Copy link
Member

Can you expand on that? We already use the new errors in the streams code, and it isn't obvious how readable-stream's semver levels relate to Node core's int hese situations_

My only concern is that this does not get into 6, 8 or 9. This is why I flagged as semver-major. I'm good with do-not-land tags for all release lines as well. I won't land this into the 2.x.x line of readable-stream, and that is currently tracking Node 8.

@addaleax addaleax added dont-land-on-v6.x author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed semver-major PRs that contain breaking changes and should be released in the next major version. labels Mar 21, 2018
@addaleax
Copy link
Member Author

addaleax commented Mar 25, 2018

BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Mar 27, 2018
Otherwise, this condition would result in an error that just reads
`cb is not a function`, and which additionally could have lost
stack trace context through a `process.nextTick()` call.

PR-URL: nodejs#19510
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@BridgeAR
Copy link
Member

Landed in d111d7b 🎉

@BridgeAR BridgeAR closed this Mar 27, 2018
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. errors Issues and PRs related to JavaScript errors originated in Node.js core. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants