GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: refactor stream_wrap by addaleax · Pull Request #16158 · nodejs/node

Conversation

@addaleax

@addaleax addaleax commented Oct 12, 2017

Copy link
Copy Markdown
Member

Another first step into making parts of the code base more accessible.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

lib/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

apapirovski reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to Node.js builds or CI infrastructure. net Issues and PRs related to the net subsystem. stream Issues and PRs related to Node.js streams. labels Oct 12, 2017
@addaleax addaleax changed the title lib: reactor stream_wrap lib: refactor stream_wrap Oct 12, 2017
fhinkel
fhinkel reviewed Oct 12, 2017
View reviewed changes
Comment thread lib/net.js Outdated

@fhinkel fhinkel Oct 12, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Add an else { error...} case here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@fhinkel fhinkel Oct 12, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Never mind, this is not an exhaustive if else.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
fhinkel
fhinkel reviewed Oct 12, 2017
View reviewed changes
Comment thread lib/internal/wrap_js_stream.js Outdated

@fhinkel fhinkel Oct 12, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

on a network resource or on network resources.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
fhinkel
fhinkel reviewed Oct 12, 2017
View reviewed changes
Comment thread lib/internal/wrap_js_stream.js Outdated

@fhinkel fhinkel Oct 12, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Nit: change to active voice:
The flipside of this is that, to maintain composability, we need a way to create ....

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
jasnell
jasnell reviewed Oct 12, 2017
View reviewed changes
Comment thread lib/internal/wrap_js_stream.js Outdated

@jasnell jasnell Oct 12, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We need to be certain that the change to the ES6 class is not going to break the planet, here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mcollina mcollina Oct 12, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think we are, there is no constructor without new in the original one.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@addaleax addaleax Oct 12, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yes. Also, this class exposes only limited functionality – you effectively can’t use it for any other purpose than what Node core does.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jasnell jasnell Oct 18, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Ok. I can't come up with anything specific that would break so I'm ++

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jasnell
jasnell reviewed Oct 12, 2017
View reviewed changes
Comment thread lib/internal/wrap_js_stream.js Outdated

@jasnell jasnell Oct 12, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

do these really need to be closures?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@addaleax addaleax Oct 12, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

They were before. Can we defer optimizing to later work?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jasnell
jasnell requested a review from mcollina October 12, 2017 12:58
fhinkel
fhinkel reviewed Oct 12, 2017
View reviewed changes
Comment thread lib/internal/wrap_js_stream.js Outdated

@fhinkel fhinkel Oct 12, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Super-Nit: period at the end of the comment.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
fhinkel
fhinkel approved these changes Oct 12, 2017
View reviewed changes
@jasnell jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Oct 12, 2017
@jasnell

jasnell commented Oct 12, 2017

Copy link
Copy Markdown
Member

Marking semver-major defensively. This is a change to an _-prefixed file, but it's one that has been around for quite some time. @ChALkeR ...would it be possible to get some insights into what (if any) userrland modules are using this that could be impacted?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina reviewed Oct 12, 2017
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Very good work! I think we can take the refactoring a bit further and avoid some closure allocations.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/_stream_wrap.js Outdated

@mcollina mcollina Oct 12, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I would deprecate this file, people should not be requiring this in any form.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@addaleax addaleax Oct 12, 2017

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

If we go with semver-major, yes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/internal/wrap_js_stream.js Outdated

@mcollina mcollina Oct 12, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think we are, there is no constructor without new in the original one.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/internal/wrap_js_stream.js Outdated

@mcollina mcollina Oct 12, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

some of those would be better of to be bind(). Now it's faster than allocating a closure.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/internal/wrap_js_stream.js Outdated

@mcollina mcollina Oct 12, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I would prefer if we could optimize this function so that it's not a closure anymore, but a top level function.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell and BridgeAR reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
Comment thread lib/internal/wrap_js_stream.js Outdated

@mcollina mcollina Oct 12, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

can we avoid allocating two closures for every write? I know it would make the code uglier, but it's probably the right moment to do.

The innermost can be replaced by a top-level function with handle, item, req and errCode as parameters. The top-level one can be allocated in the constructor, and we can store pending as an object property (maybe behind a symbol).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell and BridgeAR reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
Comment thread lib/internal/wrap_js_stream.js Outdated

@mcollina mcollina Oct 12, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

this function should really be top-level. The while loop can really get cpu-intensive.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@addaleax

addaleax commented Oct 12, 2017

Copy link
Copy Markdown
Member Author

Marking semver-major defensively. This is a change to an _-prefixed file, but it's one that has been around for quite some time. @ChALkeR ...would it be possible to get some insights into what (if any) userrland modules are using this that could be impacted?

I would be extremely surprised if something comes up. Are you marking this semver-major out of principle or because you can actually imagine a use case somebody is having?

(If somebody uses this, it’s probably @indutny because there’s basically nobody else around who knows what it does…)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Oct 12, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

@mcollina We can talk about optimizations, but this isn’t creating any new closures – can we avoid nitpicking for an actual PR that does those optimizations? Also, to reiterate what the comment states: This is the slow path. Optimizing this doesn’t actually have much real-world impact.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Oct 12, 2017

Copy link
Copy Markdown
Member

Marking it semver-major out of principle and an abundance of caution. I'm good with it landing as a patch, but we should do a small amount of due diligence first.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Oct 12, 2017

Copy link
Copy Markdown
Member Author

Yeah, we can wait for an npm search for it. :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina

mcollina commented Oct 12, 2017

Copy link
Copy Markdown
Member

Currently git is not marking these files as moved, but rather as new files. If this is marked semver-major, this makes sense, and we can as well refactor and improve them.

I think we should land this as semver-major, and spend a little more time improving this.

I propose you keep the first commit in this PR. Once that is landed, we do another PR with the ES6 refactoring and we deprecate the old file.

addaleax reacted with confused emoji
All reactions
  • 😕 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Oct 13, 2017

Copy link
Copy Markdown
Member

Definitely agree with @mcollina about wanting to avoid the closures if possible (looking them over, it should definitely be easily possible).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Oct 13, 2017

Copy link
Copy Markdown
Member Author

I don’t disagree about avoiding closures in general, but I would really say that’s not the scope of this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Oct 13, 2017

Copy link
Copy Markdown
Member Author

Also, if this is semver-major, could you give a hypothetical example of code that might break?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Oct 13, 2017

Copy link
Copy Markdown
Member

There likely isn't any, again it's only defensive. Now that I've had a moment free to do a search on github and Google and I'm not seeing anything of any concern. If we cannot really identify anything that would break, I'm good with dropping the major label.

I disagree on the closure bit but I can open a separate pr that handles that.

addaleax reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Oct 13, 2017

Copy link
Copy Markdown
Member Author

I’ll at least try to get @ChALkeR’s tooling to run again, it might be nice anyway if somebody else had practice in that (and I know I got it to build at least once) :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cjihrig
cjihrig approved these changes Oct 16, 2017
View reviewed changes
@addaleax
addaleax force-pushed the refactor-js-stream branch from 8fc47f2 to 4cd793f Compare October 17, 2017 20:35
@addaleax addaleax removed the semver-major PRs that contain breaking changes and should be released in the next major version. label Oct 17, 2017
@addaleax

addaleax commented Oct 17, 2017

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-commit/13229/
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1013/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax
lib: move _stream_wrap into internals
beb69df
This makes a subsequent possible deprecation easier.

PR-URL: nodejs#16158
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
@jasnell jasnell mentioned this pull request Oct 30, 2017
Proposal: 2017-10-31, Version 9.0.0 (Current) #15135
Merged
@addaleax addaleax mentioned this pull request Oct 30, 2017
wrap_js_stream: adding test for readStop #16356
Closed
2 tasks done
addaleax added a commit to addaleax/node that referenced this pull request Oct 30, 2017
@addaleax
lib: move _stream_wrap into internals
46dfca7
This makes a subsequent possible deprecation easier.

PR-URL: nodejs#16158
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
addaleax added a commit to addaleax/node that referenced this pull request Oct 30, 2017
@addaleax
lib: refactor wrap_js_stream for ES6/readability
7cab126
PR-URL: nodejs#16158
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
gibfahn pushed a commit that referenced this pull request Oct 30, 2017
@addaleax @gibfahn
lib: move _stream_wrap into internals
d55ea72
This makes a subsequent possible deprecation easier.

PR-URL: #16158
Backport-PR-URL: #16626
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
gibfahn pushed a commit that referenced this pull request Oct 30, 2017
@addaleax @gibfahn
lib: refactor wrap_js_stream for ES6/readability
97c2301
PR-URL: #16158
Backport-PR-URL: #16626
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
gibfahn pushed a commit that referenced this pull request Oct 31, 2017
@addaleax @gibfahn
lib: move _stream_wrap into internals
87fd5b7
This makes a subsequent possible deprecation easier.

PR-URL: #16158
Backport-PR-URL: #16626
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
gibfahn pushed a commit that referenced this pull request Oct 31, 2017
@addaleax @gibfahn
lib: refactor wrap_js_stream for ES6/readability
ab0d7a6
PR-URL: #16158
Backport-PR-URL: #16626
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
@gibfahn gibfahn mentioned this pull request Oct 31, 2017
v8.9.0 proposal #16630
Merged
@MylesBorins MylesBorins added the dont-land-on-v6.x label Nov 14, 2017
@MylesBorins

MylesBorins commented Nov 14, 2017

Copy link
Copy Markdown
Contributor

@addaleax I've added the don't land label for 6.x... lmk if we should change that

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax added a commit to ayojs/ayo that referenced this pull request Dec 7, 2017
@addaleax
lib: move _stream_wrap into internals
64078b2
This makes a subsequent possible deprecation easier.

PR-URL: nodejs/node#16158
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
addaleax added a commit to ayojs/ayo that referenced this pull request Dec 7, 2017
@addaleax
lib: refactor wrap_js_stream for ES6/readability
99afe7d
PR-URL: nodejs/node#16158
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
@addaleax addaleax added backported-to-v8.x and removed backport-requested-v8.x labels Jan 10, 2018
@sam-github sam-github mentioned this pull request Feb 21, 2019
lib: deprecate _stream_wrap #26245
Closed
3 tasks done
sam-github added a commit to sam-github/node that referenced this pull request Mar 2, 2019
@sam-github
lib: deprecate _stream_wrap
a1fb336
Its unused by node, and doesn't have a reasonable use outside of node.

See: nodejs#25153
See: nodejs#16158
sam-github added a commit that referenced this pull request Mar 4, 2019
@sam-github
lib: deprecate _stream_wrap
c7e628f
Its unused by node, and doesn't have a reasonable use outside of node.

See: #25153
See: #16158

PR-URL: #26245
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina left review comments
@jasnell jasnell jasnell left review comments
@cjihrig cjihrig cjihrig approved these changes
@tniessen tniessen tniessen approved these changes
+1 more reviewer
@fhinkel fhinkel fhinkel approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

build Issues and PRs related to Node.js builds or CI infrastructure. net Issues and PRs related to the net subsystem. stream Issues and PRs related to Node.js streams.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@addaleax @jasnell @mcollina @MylesBorins @fhinkel @cjihrig @tniessen @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.