Uh oh!
There was an error while loading. Please reload this page.
net: use actual Timeout instances on Sockets - #11154
Conversation
There was a problem hiding this comment.
Can you remove the commented code.
There was a problem hiding this comment.
Maybe a result of the commented code, but this could be
if (s._timeout)
timers._unrefActive(s._timeout);
14bebdf to
18ef0d0CompareFishrock123
commented
Feb 3, 2017
Ah right, forgot to remove that before PRing. Updated, new CI: https://ci.nodejs.org/job/node-test-pull-request/6203/ |
There was a problem hiding this comment.
Rather than introducing yet another _ prefixed property, I'd much prefer to use a Symbol.
Also, given that I'm following an identical pattern in the http2 work, I'd like that Symbol to be reusable (perhaps as an export off the internal/timers.js this PR creates
There was a problem hiding this comment.
Isn't that part of the implementation of a Timeout instance? i.e. didn't a socket already have it, it just wasn't declared in the constructor?
There was a problem hiding this comment.
Not that I'm able to see. There are zero hits anywhere in the source for a _timeout property
There was a problem hiding this comment.
It gets added if Socket#setTimeout() is called iirc https://github.com/nodejs/node/blob/master/lib/net.js#L330
There was a problem hiding this comment.
Again, not that I'm able to see: https://github.com/nodejs/node/blob/master/lib/timers.js#L296-L317
There was a problem hiding this comment.
Apologies, I was thinking of ._idleTimeout. Disregard
Fishrock123
commented
Feb 3, 2017
It should be noted that in situations where timer properties were previously available on the Socket object, they will not be after this patch. I highly doubt people rely on those though, since they may not always be there to begin with. |
There was a problem hiding this comment.
Can timers.js re-use this value by importing it from here?
lpinca
commented
Feb 4, 2017
Isn't this semver-major? |
jasnell
commented
Feb 4, 2017
I think I would lean more towards semver-major on this, just to be careful |
evanlucas
commented
Feb 4, 2017
+1 to Semver-major |
Fishrock123
commented
Feb 4, 2017
Theoretically |
Fishrock123
commented
Feb 10, 2017
Fishrock123
commented
Feb 10, 2017
Addressed most of the remaining comments. @jasnell I made the new property hidden using a |
jasnell
commented
Feb 10, 2017
We should be safe but if someone really needed that access then adding a new API shouldn't be out of the question. |
jasnell
commented
Mar 22, 2017
@Fishrock123 ... ping... what's the status on this one? |
Fishrock123
commented
Mar 22, 2017
Ugh, I'm just worried that we will end up breaking some module or something. Would anyone be calling e.g. ... new CI: https://ci.nodejs.org/job/node-test-pull-request/6985/ Guess we might as well land if it looks good. @nodejs/ctc if anyone else has significant reservations. |
mscdex
commented
Mar 22, 2017
Can the new internal module use the |
768f5ec to
3c49be6CompareFishrock123
commented
Mar 22, 2017
@mscdex Done, updated and rebased. |
There was a problem hiding this comment.
I prefer 'positive, finite number'. I recall having a similar discussion in a previous PR about using 'non-negative' vs 'positive' in error messages. To me it sounds more straight-forward.
As far as including the original value in the error message goes, I don't know if we've "standardized" on how it's presented, but to me the current wording is a little awkward. Perhaps it could be more explicit, like
'... must be a positive, finite number. Saw value: '+msecsor
'... must be a positive, finite number. Received value: '+msecsThere was a problem hiding this comment.
Zero is an allowed value but is not a positive number, though.
There was a problem hiding this comment.
Zero can be positive or negative, at least as far as Javascript is concerned.
There was a problem hiding this comment.
FWIW here was the previous PR I had in mind where "non-negative" was dropped in favor of "positive": #10769
Fishrock123
commented
Apr 23, 2017
@mscdex Does any of this really matter, since it is internal anyways? |
I think to check the performance difference of these changes, we'd need to either create a new benchmark or possibly run one of the http benchmarks (since timeouts may be used there) because those in benchmarks/net do not exercise |
mscdex
commented
Apr 23, 2017
@Fishrock123 What do you mean "any of this?" |
Just to add, just because this function is internal does not mean suggestions should be ignored, especially because functions like |
BridgeAR
commented
Aug 30, 2017
@Fishrock123 this needs a rebase |
BridgeAR
commented
Sep 20, 2017
I am closing this due to long inactivity and no response. @Fishrock123 please reopen if you would like to follow up on this. |
Fishrock123
commented
Oct 7, 2017
This is something I am still interested in pursuing in the very near future. |
Fishrock123
commented
Nov 14, 2017
Still very busy but on my short-term todo list |
8ca9329 to
0113d10CompareBridgeAR
commented
Nov 22, 2017
@Fishrock123 I did not fully check if all comments were addressed or if you just rebased. Could you have another look? :-) |
BridgeAR
commented
Nov 22, 2017
Fishrock123
commented
Nov 23, 2017
FUN FACT: this patch still needed all those internal checks! ... |
0113d10 to
606abb3CompareThis should fail: https://ci.nodejs.org/job/node-test-pull-request/11650/ I can't get these to pass, I'm not sure why a Edit: to clarify, it fails to parse the request chunk... somehow. cc @nodejs/http |
All type checking done in this patch is necessary for consistency with other parts of the code. If you want it changed open a separate PR. |
Fishrock123
commented
Dec 15, 2017
Just gona open a new PR. |
This makes
net.Sockets use actualTimeoutobjects in a_timeoutproperty, rather than making the socket itself a timer and appending properties to it directly.This should make the code generally easier to understand, and might also prevent some deopts from properties being changes on the socket itself.
It is possible this could effect performance either better or worse, but I highly doubt it would be a significant difference. I'll try to run benchmarks on it in the coming days, but if anyone else would like to that would also be appreciated.
This also exposes
timers.Timeoutso as to avoid a circular dependency with the newlib/internal/timers.js, but we might not want that so I should be able to refactor more of timers into the internals file if necessary. Tagging assemver-minorfor now due to this. I could also split that into separate commits.Made live on https://twitch.tv/nodesource
CI: https://ci.nodejs.org/job/node-test-pull-request/6202/
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
net, timers