Skip to content

Conversation

@mscdex
Copy link
Contributor

@mscdexmscdex commented Jan 21, 2017

This is one proposed solution to the current backwards compatibility issue (see #10558) in master with end users who directly access outgoingMessage._headers/outgoingMessage._headerNames.

This PR will be simplified some once #10805 is landed (which should land before this PR). Specifically, the ._headers getter can simply just return this.getHeaders().

/cc @nodejs/collaborators

CI: https://ci.nodejs.org/job/node-test-pull-request/6054/

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)
  • http

@mscdexmscdex added http Issues or PRs related to the http subsystem. wip Issues and PRs that are still a work in progress. labels Jan 21, 2017
@nodejs-github-botnodejs-github-bot added http Issues or PRs related to the http subsystem. dont-land-on-v7.x labels Jan 21, 2017
@mscdexmscdex mentioned this pull request Jan 21, 2017
3 tasks
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use a Symbol to hide it more?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Does accessing a value via a Symbol have a perf hit vs. normal property access in master?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know. I'll look into making a benchmark.

Copy link
Member

@targostargosJan 21, 2017

Choose a reason for hiding this comment

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

Results with the following benchmark (is it worth adding to the repo?): targos@d50c790

# master $ ./node benchmark/es/object-property-bench.js es/object-property-bench.js millions=1000 method="property": 1,137.5161172810194 es/object-property-bench.js millions=1000 method="string": 1,133.78613592118 es/object-property-bench.js millions=1000 method="variable": 1,137.9577172760735 es/object-property-bench.js millions=1000 method="symbol": 1,133.090467628974 # v7.4.0 $ node benchmark/es/object-property-bench.js es/object-property-bench.js millions=1000 method="property": 1,136.7741112855451 es/object-property-bench.js millions=1000 method="string": 1,136.7865674716409 es/object-property-bench.js millions=1000 method="variable": 1,135.1437992275612 es/object-property-bench.js millions=1000 method="symbol": 1,136.4064052769731 # v4.7.1 $ node benchmark/es/object-property-bench.js es/object-property-bench.js millions=1000 method="property": 1,135.4850535131566 es/object-property-bench.js millions=1000 method="string": 1,134.4381133016345 es/object-property-bench.js millions=1000 method="variable": 78.62998231306928 es/object-property-bench.js millions=1000 method="symbol": 81.82481813228071

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ok so it might be worth sticking to properties for now.

As far as adding the benchmark, it could be useful. Although I'd probably put it in misc/ instead of es/ since it doesn't primarily deal with es6+ alternatives (which es/ seems to contain).

Copy link
Member

Choose a reason for hiding this comment

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

it might be worth sticking to properties for now

I don't think so. The numbers are very close and on multiple runs, the order varies a lot. It would be worth only for v4.x

Copy link
Member

Choose a reason for hiding this comment

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

@targos@mscdex this matches my findings. In practice I did not see any perf impact in using symbols since v7.

Copy link
Member

Choose a reason for hiding this comment

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

I've been testing this like crazy lately and from everything I have seen there is essentially zero perf impact from using symbols.

@jasnell
Copy link
Member

+1 to using a symbol instead.

@mscdexmscdexforce-pushed the http-outgoingmessage-headers-deprecate branch from fd32784 to 16bd79cCompareJanuary 25, 2017 21:20
@mscdex
Copy link
ContributorAuthor

@mscdexmscdex removed dont-land-on-v7.x wip Issues and PRs that are still a work in progress. labels Jan 25, 2017
@thefourtheye
Copy link
Contributor

Isn't this a major change?

@jasnelljasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jan 30, 2017
@addaleaxaddaleax added this to the 8.0.0 milestone Feb 15, 2017
@mscdexmscdex mentioned this pull request Feb 19, 2017
3 tasks
@ChALkeRChALkeR self-requested a review February 19, 2017 09:31
@mscdex
Copy link
ContributorAuthor

This PR needs at least one more approval from a @nodejs/ctc member in order for it to land (again, after #10805 lands).

@mscdexmscdexforce-pushed the http-outgoingmessage-headers-deprecate branch 2 times, most recently from ce2aab4 to 953b97eCompareFebruary 20, 2017 22:32
@mscdex
Copy link
ContributorAuthor

Updated PR to use one of the new http API methods and to reuse StorageObject instead of another custom storage object constructor.

CI: https://ci.nodejs.org/job/node-test-pull-request/6518/

@rvagg
Copy link
Member

do we have any ecosystem usage metrics for this? that's my only concern before agreeing.

@mscdex
Copy link
ContributorAuthor

mscdex commented Feb 21, 2017

@rvagg I don't know, all I can do is run in CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/586/

express/send has already started the process of migrating to using the existing getHeader() instead of _headers FWIW.

@rvagg
Copy link
Member

@ChALkeR are you still the one to find this data?

@dougwilson
Copy link
Member

P.S. I know I shouldn't have done this, but had some code that was

functionclearHeaders(res){res._headers={}res._headerNames={}}

Obviously needs to change. Right now works on Node.js 8, but this landing will break even that without any warning. Should probably keep that working with a warning if the getters would keep working, right?

@mscdex
Copy link
ContributorAuthor

mscdex commented Feb 22, 2017

@dougwilson Yeah I'm not sure what the best solution to that would be as far as the behavior of the setter, since we'd probably have to just copy the values out of the object instead of just using the same object reference (because the internal representation changed). Should we blindly copy values in the ._headers setter or should we pass each name and value to .setHeader()?

Thoughts on this @nodejs/collaborators ?

@mscdex
Copy link
ContributorAuthor

I'll land this on Tuesday if there are no more objections before then.

Here's another CI: https://ci.nodejs.org/job/node-test-pull-request/6720/

@mikeal
Copy link
Contributor

It looks like a lot of reverse compatibility work has been done here, can we get a redux of what won't work anymore after this change?

@evanlucas
Copy link
Contributor

I'm still a bit concerned with deprecating res._headers. Although it isn't documented as a public api, it is used in so many places. Is it really justifiable to break the ecosystem like this?

@mscdex
Copy link
ContributorAuthor

@mikeal As far as I know there shouldn't really be any difference with the getters/setters in place.

@evanlucas I don't understand the concern, there is no runtime deprecation anymore. It's a documentation deprecation. Also there are now other public http APIs that cover all of the use cases I've seen thus far for accessing the private properties.

@mscdexmscdexforce-pushed the http-outgoingmessage-headers-deprecate branch from 8126753 to 0cc96d1CompareMarch 7, 2017 01:33
@evanlucas
Copy link
Contributor

@mscdex even with a docs only deprecation, that still more than likely means we are going to remove it eventually. I'm just not sure whether it is justified.

I do seem to be in the minority on this one though so ¯\(ツ)

@mscdex
Copy link
ContributorAuthor

mscdex commented Mar 8, 2017

@evanlucas Well yes, that is the plan for deprecations. I don't see how it's a problem considering it's only a docs deprecation for v8.0.0 and there are public methods that cover the current use cases for these private properties (these methods should be backported to v4.x and v6.x). IMHO there will be plenty of time for people to convert their code to use these new methods before the old, private properties become a runtime deprecation and eventually removed.

This PR also fixes a backwards compatibility issue that currently exists in master, so that is why I've been wanting to get this landed sooner than later.

@mscdexmscdexforce-pushed the http-outgoingmessage-headers-deprecate branch from 0cc96d1 to 9be372fCompareMarch 9, 2017 08:43
@mscdex
Copy link
ContributorAuthor

mscdex added 4 commits March 9, 2017 05:50
PR-URL: nodejs#10941 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
PR-URL: nodejs#10941 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
PR-URL: nodejs#10941 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
PR-URL: nodejs#10941 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
@mscdexmscdexforce-pushed the http-outgoingmessage-headers-deprecate branch from 9be372f to 8243ca0CompareMarch 9, 2017 10:50
@mscdexmscdex changed the title http: add deprecation warnings for private propshttp: add doc deprecation for private propsMar 9, 2017
@mscdexmscdex merged commit 8243ca0 into nodejs:masterMar 9, 2017
@mscdexmscdex deleted the http-outgoingmessage-headers-deprecate branch March 9, 2017 10:52
jungx098 pushed a commit to jungx098/node that referenced this pull request Mar 21, 2017
PR-URL: nodejs#10941 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
jungx098 pushed a commit to jungx098/node that referenced this pull request Mar 21, 2017
PR-URL: nodejs#10941 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
jungx098 pushed a commit to jungx098/node that referenced this pull request Mar 21, 2017
PR-URL: nodejs#10941 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
jungx098 pushed a commit to jungx098/node that referenced this pull request Mar 21, 2017
PR-URL: nodejs#10941 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
@jasnelljasnell mentioned this pull request Apr 4, 2017
@tniessentniessen added the deprecations Issues and PRs related to deprecations. label Sep 7, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecationsIssues and PRs related to deprecations.httpIssues or PRs related to the http subsystem.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

15 participants

@mscdex@jasnell@thefourtheye@rvagg@dougwilson@ChALkeR@mikeal@evanlucas@mcollina@benjamingr@targos@cjihrig@addaleax@tniessen@nodejs-github-bot