-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
http: clean up dead code and unused properties #1572
Conversation
stream.push(null); | ||
} | ||
|
||
if (stream && !parser.incoming._pendings.length) { |
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 is the only place I could find where ._pendings
was actually used, so since nothing was ever added to the array, the second part of the conditional was always evaluating to true. Thus, the stream.push(null)
can be merged up above.
@@ -49,7 +47,6 @@ function IncomingMessage(socket) { | |||
// response (client) only | |||
this.statusCode = null; | |||
this.statusMessage = null; | |||
this.client = this.socket; |
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'd rather we deprecate this property than delete it outright.
Other than the deprecation preference, LGTM. |
@chrisdickinson I added a deprecation notice for |
@@ -63,6 +60,9 @@ util.inherits(IncomingMessage, Stream.Readable); | |||
|
|||
exports.IncomingMessage = IncomingMessage; | |||
|
|||
IncomingMessage.prototype.__defineGetter__('client', util.deprecate(function() { |
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 prefer Object.defineProperty
(like so, with a util.deprecate
'd getter function as you have here), but otherwise this looks good!
@@ -613,8 +611,7 @@ OutgoingMessage.prototype._flush = function() { | |||
var outputEncodings = this.outputEncodings; | |||
var outputCallbacks = this.outputCallbacks; | |||
for (var i = 0; i < outputLength; i++) { | |||
ret = socket.write(output[i], outputEncodings[i], | |||
outputCallbacks[i]); | |||
ret = socket.write(output[i], outputEncodings[i], outputCallbacks[i]); |
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 you undo the style changes in this file?
LGTM with a request. |
get: util.deprecate(function() { | ||
return this.socket; | ||
}, 'client is deprecated, use socket or connection instead') | ||
}); |
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.
might still want to support set here also if this is not semver-major
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.
What would the setter do? Throw a deprecation error? Set this.socket
? Set this.client
again? Something else?
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.
would set this.socket
. Could also throw a dep error I suppose.
7fee207
to
ebe5d52
Compare
}, 'client is deprecated, use socket or connection instead'), | ||
set: util.deprecate(function(val) { | ||
this.socket = this.connection = val; | ||
}, 'client is deprecated, use socket or connection instead') |
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.
Sorry, just saw this. We should use set to change this.client
to whatever the passed value is, while not affecting socket
.
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.
(As written this changes behavior – previously setting .client
would not affect .socket
.)
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.
ah, so it should initially be set to this.socket
then?
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.
Wait, if the setter is changing this.client
, wouldn't we have to change the underlying property name (e.g. to something like this._client
) otherwise it would lead to some kind of loop (setting this.client
inside a this.client
setter)?
set: util.deprecate(function(val) { | ||
this._client = val; | ||
}, 'client is deprecated, use socket or connection instead') | ||
}); |
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.
Of course, this will break if anyone is trying to do delete req.client
for whatever reason..
LGTM, @chrisdickinson? |
I think @chrisdickinson already signed off . |
PR-URL: #1572 Reviewed-By: Chris Dickinson <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
Landed in 1eec5f0. |
I'd like to state for the record that I'm pretty annoyed that this landed in a non-semver major version of io.js, as it is, as we have seen in #1808 with As @ceejbot says here and here:
Just because |
I'm not up to date with #1704, but that contains the WIP deprecation policy, which you might be interested in. http.IncomingRequest.client isn't documented anyways, and I doubt we are going to document a deprecation on something that isn't documented in the first place. A warning should do I think, and it shouldn't effect anything.
The core problem here was oversight of this point, not what you are making it to be.
It landed in a minor, so far deprecations have been fine to land in minors?
This isn't actually correct. For example, there is no way we could possibly rename or change In the mean time, we're tying to fix the actual oversight of |
As I discuss below, its lack of documentation is immaterial to this discussion, and is also probably a bug in the documentation, strictly speaking.
That seems to directly contradict the actual experience we're having right now.
I'm talking about the removal of
That's the converse of the quoted section's point – the important thing here is that properties are a part of the object's interface, documented or not. Expectations are higher on platforms than they are on tooling, and they're higher on tooling than they are on simple libraries or applications. |
Right, because we did it incorrect on a technical level and overlooked
I'm not really sure I'd consider replacing something with deprecation getter/setters as a "removal", but we still do have to be careful yes. However, as @mscdex mentioned to me in irc, doing things that don't work with getters, like
Right, because I agree with the former, but |
@Fishrock123 Deleting properties of the core objects was never supported and should never be used, it's an undefined behaviour. For example, |
Renaming properties on objects created by Node core modules should be considered a breaking change, whether prefixed with the conventional The right fix is a process & tooling fix, so humans are not continually burdened by having to deal with this & think about the ramifications of every change. Part of the release acceptance should be a tool that runs I would be willing to help make this so. |
@ceejbot I always thought that |
@ceejbot I've thought about having a suite of userland modules to test (As Rust is recently doing), however, to fully cover it there are two important points:
Is there any way around the latter? I think we have access to more resources now to set something up like this, but I doubt I'll have time to work anything out in the next 2? weeks. |
Build is working on npm package smoke tests over here: nodejs/build#82 |
@Fishrock123 Shouldn't running tests be as simple as |
|
PR-URL: nodejs/node#1572 Reviewed-By: Chris Dickinson <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
No description provided.