-
Notifications
You must be signed in to change notification settings - Fork 97
timers: warn on overflowed timeout duration #71
Conversation
Could you explain what you mean about "hitting the overflow"? I'm a bit confused by it. Edit: as I understand the code, it means if a timeout or interval is given a number higher than the mac allowrd (32bit int?). It makes sense to warn when this happens, imo. But why does the limit exist? Edit2: also, it seems that rn it is coerced to TIMEOUT_MAX, instead of 1 as in browsers (per your original message)? |
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.
Looks good to me, but yeah, I wonder, what keeps us from supporting longer timeouts? libuv seems to support them?
@hypesystem see Lines 46 to 47 in edc403c
When a timer's duration is longer than that. @addaleax in the OP:
|
@Fishrock123 realized I was a bit quick. Updated the original comment with better questions 😄 |
|
@Fishrock123 why is the browser behavior the best though? Is it really necessary to follow that? I think it would be best to just increase the maximum instead. |
Is there any particular reason that nodejs/node#6956 wasn't pursued? It seemed like a reasonable change. edited by @TimothyGu to fix link |
Best? Not really. Consider that the maximum using 32 bits is already some ~26 days or so in length.
At the time, time&energy. Now-ish? Wanted to see how PRing to Ayo will be like. Also a part of me would kinda like to deal with less potential edge-case nonsense fallout since historically people just yell more when there are warnings, useful or not. ¯\_(ツ)_/¯ |
b17d7b6
to
2045a3d
Compare
Previously there wasn't any clear indicator when you hit the overflow other than possibly unexpected behavior, and I think emitting a warning may be appropriate. PR-URL: ayojs#71
It appears the linter run from travis didn't catch some long lines? Any idea why @addaleax? |
heh … I don’t think Travis is actually running the linter – my bad, sorry! |
@@ -538,8 +548,15 @@ exports.setInterval = function(callback, repeat, arg1, arg2, arg3) { | |||
|
|||
function createRepeatTimeout(callback, repeat, args) { | |||
repeat *= 1; // coalesce to number or NaN | |||
if (!(repeat >= 1 && repeat <= TIMEOUT_MAX)) | |||
if (!(repeat >= 1 && repeat <= TIMEOUT_MAX)) { |
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.
Is it feasible to avoid duplicating code in createSingleTimeout()
and createRepeatTimeout()
?
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.
Is the emitWarning
call the duplicate code you're referring to?
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.
The warning message differs slightly.
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.
Yeah, that's what I was going to say. Doesn't seem worth abstracting, IMO.
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.
Yup, sorry, didn't notice the difference in warning messages.
|
||
const OVERFLOW = Math.pow(2, 31); // TIMEOUT_MAX is 2^31-1 | ||
|
||
function TimerNotCanceled() { |
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 say this function's name should start with a lowercase letter.
It's be nice to have it run as a separate task, but I think this should work for now. Refs: ayojs/ayo#71
It'd be nice to have it run as a separate task, but I think this should work for now. Refs: ayojs#71
Previously there wasn't any clear indicator when you hit the overflow other than possibly unexpected behavior, and I think emitting a warning may be appropriate. PR-URL: ayojs#71
2045a3d
to
7d216e4
Compare
Divides the CI jobs by a custom `matrix:`, with a new linter job using an existing node.js binary to run `make lint-ci` (eslint). Refs: ayojs#71
I suppose this should be land-able if it is something ya'll think would be good? |
Previously there wasn't any clear indicator when you hit the overflow other than possibly unexpected behavior, and I think emitting a warning may be appropriate. PR-URL: ayojs/ayo#71
Yeah, seems reasonable to me. |
Previously there wasn't any clear indicator when you hit the overflow other than possibly unexpected behavior, and I think emitting a warning may be appropriate. PR-URL: #71 Reviewed-By: Scott Trinh <scott@scotttrinh.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
@Fishrock123 yup, thanks for the ping! Landed in 607316c! |
Cherry-pick from ayo Ayo commit log: > Previously there wasn't any clear indicator when you hit the overflow > other than possibly unexpected behavior, and I think emitting a warning > may be appropriate. > PR-URL: ayojs/ayo#71 > Reviewed-By: Scott Trinh <scott@scotttrinh.com> > Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> > Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> > Reviewed-By: Anna Henningsen <anna@addaleax.net> > Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Cherry-pick from ayo Ayo commit log: > Previously there wasn't any clear indicator when you hit the overflow > other than possibly unexpected behavior, and I think emitting a warning > may be appropriate. > PR-URL: ayojs/ayo#71 > Reviewed-By: Scott Trinh <scott@scotttrinh.com> > Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> > Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> > Reviewed-By: Anna Henningsen <anna@addaleax.net> > Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> PR-URL: #15627 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Cherry-pick from ayo Ayo commit log: > Previously there wasn't any clear indicator when you hit the overflow > other than possibly unexpected behavior, and I think emitting a warning > may be appropriate. > PR-URL: ayojs/ayo#71 > Reviewed-By: Scott Trinh <scott@scotttrinh.com> > Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> > Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> > Reviewed-By: Anna Henningsen <anna@addaleax.net> > Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> PR-URL: #15627 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Cherry-pick from ayo Ayo commit log: > Previously there wasn't any clear indicator when you hit the overflow > other than possibly unexpected behavior, and I think emitting a warning > may be appropriate. > PR-URL: ayojs/ayo#71 > Reviewed-By: Scott Trinh <scott@scotttrinh.com> > Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> > Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> > Reviewed-By: Anna Henningsen <anna@addaleax.net> > Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> PR-URL: #15627 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Cherry-pick from ayo Ayo commit log: > Previously there wasn't any clear indicator when you hit the overflow > other than possibly unexpected behavior, and I think emitting a warning > may be appropriate. > PR-URL: ayojs/ayo#71 > Reviewed-By: Scott Trinh <scott@scotttrinh.com> > Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> > Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> > Reviewed-By: Anna Henningsen <anna@addaleax.net> > Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> PR-URL: #15627 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Previously there wasn't any clear indicator when you hit the overflow
other than possibly unexpected behavior, and I think emitting a warning
may be appropriate.
While it may be viable to allow the use of 64bit numbers in
enroll()
, browsersetTimeout
/setInterval
just coerces it to1
, which we've been roughly following so far.I previously had a PR for this at nodejs/node#6956 but I didn't really take it anywhere at the time.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
timers