-
Notifications
You must be signed in to change notification settings - Fork 75
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)? |
addaleax
left a comment
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! |
| 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
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: #71 PR-URL: #75 Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
|
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 <[email protected]> Reviewed-By: Alexey Orlenko <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
|
@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 <[email protected]> > Reviewed-By: Alexey Orlenko <[email protected]> > Reviewed-By: Stephen Belanger <[email protected]> > Reviewed-By: Anna Henningsen <[email protected]> > Reviewed-By: Benjamin Gruenbaum <[email protected]>
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 <[email protected]> > Reviewed-By: Alexey Orlenko <[email protected]> > Reviewed-By: Stephen Belanger <[email protected]> > Reviewed-By: Anna Henningsen <[email protected]> > Reviewed-By: Benjamin Gruenbaum <[email protected]> PR-URL: #15627 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
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 <[email protected]> > Reviewed-By: Alexey Orlenko <[email protected]> > Reviewed-By: Stephen Belanger <[email protected]> > Reviewed-By: Anna Henningsen <[email protected]> > Reviewed-By: Benjamin Gruenbaum <[email protected]> PR-URL: #15627 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
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 <[email protected]> > Reviewed-By: Alexey Orlenko <[email protected]> > Reviewed-By: Stephen Belanger <[email protected]> > Reviewed-By: Anna Henningsen <[email protected]> > Reviewed-By: Benjamin Gruenbaum <[email protected]> PR-URL: #15627 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
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 <[email protected]> > Reviewed-By: Alexey Orlenko <[email protected]> > Reviewed-By: Stephen Belanger <[email protected]> > Reviewed-By: Anna Henningsen <[email protected]> > Reviewed-By: Benjamin Gruenbaum <[email protected]> PR-URL: #15627 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
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/setIntervaljust 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