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

writeable stream: group all properties #31187

Closed
wants to merge 1 commit into from

Conversation

antsmartian
Copy link
Contributor

@antsmartian antsmartian commented Jan 5, 2020

Refs: #31144 for writable streams.

cc @nodejs/streams

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

@nodejs-github-bot nodejs-github-bot added the stream Issues and PRs related to the stream subsystem. label Jan 5, 2020
@antsmartian antsmartian force-pushed the writable_refactor branch 3 times, most recently from 52819a8 to 88f20ec Compare January 5, 2020 06:10
lib/_stream_writable.js Outdated Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
if (this._writableState === undefined) {
return false;
destroyed: {
enumerable: false,
Copy link
Member

@ronag ronag Jan 5, 2020

Choose a reason for hiding this comment

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

I think ObjectDefineProperties defaults enumerable to false, so I don't think these are needed? I'm not sure I understand the above comment about making it explicit? @BridgeAR any idea who is the original author of this comment?

Copy link
Contributor Author

@antsmartian antsmartian Jan 5, 2020

Choose a reason for hiding this comment

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

@ronag: That's a good point. I guess we no need to add these properties. For example, I tested the below code and by default the enumerable property is false:

const a = {}
Object.defineProperties(a, { test: { get() { return 'test'} } })
a.test // test
a.propertyIsEnumerable('test') // false

Edit: Guess you have wrongly pinged instead of me :)

Copy link
Member

Choose a reason for hiding this comment

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

Seems like that was Calvin. Some people prefer explicit descriptor properties. Probably because not everyone is handling descriptors frequently and knows that their defaults are all false. It should be fine either way.

Copy link
Member

Choose a reason for hiding this comment

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

As this also came up in #31287 (comment):

I think it’s better to be explicit here, regardless of what people may know about the default values; partly because it removes cognitive overhead of figuring out what the behaviour is, partly because making it explicit forces code authors to be deliberate about the values they choose.

lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
@antsmartian
Copy link
Contributor Author

@ronag Done. @lpinca: Removed enumerable definition as mentioned here: #31187 (comment)

Could you PTAL again?

lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
@@ -198,7 +199,7 @@ ObjectDefineProperty(WritableState.prototype, 'buffer', {
get: internalUtil.deprecate(function writableStateBufferGetter() {
return this.getBuffer();
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' +
'instead.', 'DEP0003')
'instead.', 'DEP0003')
Copy link
Member

Choose a reason for hiding this comment

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

Accidental change?

Copy link
Member

@lundibundi lundibundi left a comment

Choose a reason for hiding this comment

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

LGTM

lib/_stream_writable.js Outdated Show resolved Hide resolved
lib/_stream_writable.js Outdated Show resolved Hide resolved
Copy link
Member

@lpinca lpinca left a comment

Choose a reason for hiding this comment

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

Still LGTM with nits addressed.

lib/_stream_writable.js Outdated Show resolved Hide resolved
Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

LGTM with the comments addressed.

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

Pile-on "LGTM with nits addressed"

Trott pushed a commit that referenced this pull request Jan 9, 2020
PR-URL: #31236
Refs: #31187
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@BridgeAR
Copy link
Member

Ping @antsmartian

@antsmartian
Copy link
Contributor Author

antsmartian commented Jan 13, 2020

Sorry for delay, taken care the comments.. cc @BridgeAR @nodejs/streams

@nodejs-github-bot
Copy link
Collaborator

MylesBorins pushed a commit that referenced this pull request Jan 16, 2020
PR-URL: #31236
Refs: #31187
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
lib/_stream_writable.js Outdated Show resolved Hide resolved
@addaleax
Copy link
Member

addaleax commented Feb 7, 2020

@antsmartian Can you sqaush the commits here together? CI detects a merge conflict in one of the earlier ones that is then resolved later, but it still fails to rebase because of that. (Also happy to do that for you if you prefer.)

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

ronag commented Feb 9, 2020

Another property Writable.writable was added in e559842 which should probably also be included.

@nodejs-github-bot
Copy link
Collaborator

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

antsmartian commented Feb 10, 2020

@addaleax PTAL.. This should be fine now.

@addaleax
Copy link
Member

Landed in 0ac04ec 🙂

@addaleax addaleax closed this Feb 10, 2020
addaleax pushed a commit that referenced this pull request Feb 10, 2020
PR-URL: #31187
Refs: #31144
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@MylesBorins
Copy link
Contributor

Hey All,

this doesn't land cleanly on v13.x should there be a backport?

@mcollina
Copy link
Member

mcollina commented Mar 9, 2020

A backport will be good to have to avoid future conflicts.

ronag pushed a commit to nxtedition/node that referenced this pull request Mar 9, 2020
PR-URL: nodejs#31187
Refs: nodejs#31144
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Backport-PR-URL: nodejs#32164
MylesBorins pushed a commit that referenced this pull request Mar 10, 2020
Backport-PR-URL: #32164
PR-URL: #31187
Refs: #31144
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Mar 10, 2020
codebytere pushed a commit that referenced this pull request Mar 14, 2020
PR-URL: #31236
Refs: #31187
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
targos pushed a commit that referenced this pull request Apr 20, 2020
Backport-PR-URL: #32164
PR-URL: #31187
Refs: #31144
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
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. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.