-
Notifications
You must be signed in to change notification settings - Fork 30k
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
timer: ref/unref return self #2905
Conversation
Most calls to ref() and unref() are chainable, timers should be chainable, too. Typical use: var to = setTimeout(ontimeout, 123).unref();
LGTM |
Seems fine to me? LGTM. CI for good measure: https://ci.nodejs.org/job/node-test-pull-request/316/ |
Thanks, I'll merge after CI is green. |
And after @trevnorris chimes in. |
I initially planned on doing this in #1768 (comment), but the locked API intimitated me back then. I wouldn't expect breakage from this, thought, so +1 from me. |
@@ -345,6 +347,7 @@ Timeout.prototype.close = function() { | |||
} else { | |||
exports.unenroll(this); | |||
} | |||
return this; | |||
}; |
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.
BTW: Can we either document close
or make it _close
?
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.
Probably can't rename it, maybe could document it, though I don't know if it has a use case. Isn't the timer API inherited from browsers?
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.
Node's Timer API is pretty different from what browsers use. Browsers return numerical IDs while we return Timeout objects. I'd say if there's no public use case, we should move it to _close
.
In the long run, I'd like to see us getting closer to the standardized WindowTimers which means returning numerical values, and possibly introduce helper methods for added functionality (Timer#ref
for example).
@silverwind Agreed that this doesn't voilate the conceptual "Locked" status. LGTM |
Most calls to ref() and unref() are chainable, timers should be chainable, too. Typical use: var to = setTimeout(ontimeout, 123).unref(); PR-URL: #2905 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trevor Norris <trevnorris@nodejs.org>
Landed in 94e663a |
Can we give PRs like this a bit more time so collaborators get a chance to voice their opinion? We should at least try to leave roughly 48 hours before landing important changes as stated in the collaborator guide. Just two hours is definitely not enough imho, even with the amount of LGTM's this has. Also, my question about |
thanks for that @silverwind, 2 hours between PR and landing is a bit extreme, remember that we're dealing with devs around the world with very different schedules from each other and we need to provide opportunity for input to make the most of the broad collaborator group |
I was the under the impression that trivial changes regularly land in under 48 hours, but I will wait longer next time. @silverwind I didn't ignore your comment, I responded to it, but your comment was also wholly unrelated to my PR. You suggest documenting a previously undocumented API: maybe a good idea, maybe not, but not related to chainability of ref/unref. You also suggested renaming that API: again, maybe a good idea, maybe not, but also unrelated to chaining of ref/unref. Using this PR to have a conversation about some other thing you'd like to change in code nearby is fine by me, but it didn't appear to me to be have any impact on the progress of this PR. Am I misunderstanding your comment? |
Also, @silverwind, you |
@rvagg there are 4 doc PRs (not including the two I did) and one change to Buffer that have landed within the last day with less than a day since PR, unless I misread https://github.com/nodejs/node/pulls How hard is that 48 hour guideline? Does it apply to everything, even docs? And is it 48 hours since initial PR, or 48 hours since last comment? |
Well, you do not mention the change to |
The fact that this has to be labelled One reason for delaying merging and allowing time for feedback is that there's a ton of collective knowledge about Node, how it's used, its history and the details of various discussions that may have happened. In this case, there may be reasons that we've decide to not make these APIs chainable, perhaps there's a bigger plan to do something else with these APIs that are ruled out by returning Also, the collaborator team brings such a broad range of skills an expertise to the project and we need to maximise our use of them—some people are good at reviewing JavaScript, some people understand V8 better, some are obsessed with performance, etc. so a big reason for allowing time is to make sure we make full use of the entire team. I don't mean to pick on you here @sam-github, there's been plenty of examples of unnecessarily quick merges, I think this is a topic that we're going to be continually revisiting and calibrating. Lastly, unless a change is required to get a release out, there's no reason to rush, let's be more slow and intentional about this and be sure to lean on each other. |
I'm not "hiding" anything, the commit message is already 3 times longer than the 6 word code change, it didn't seem noteworthy. I changed close because it was there, and not changing it would lead to inconsistent code. @silverwind you would prefer close not to return this? |
No, that's fine, even thought I'm not sure when you'd want to chain off More importantly, I noticed the |
I think you are neglecting to consider the assignment part of the example, its not optional, you can't call
With this change, |
Most calls to ref() and unref() are chainable, timers should be chainable, too. Typical use: var to = setTimeout(ontimeout, 123).unref(); PR-URL: #2905 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trevor Norris <trevnorris@nodejs.org>
Most calls to ref() and unref() are chainable, timers should be
chainable, too.
Typical use:
/to @trevnorris This doesn't appear to me to have performance implications, look OK to you?