Skip to content

Commit

Permalink
Add documentation comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Annika committed Oct 21, 2020
1 parent d89de46 commit abe4409
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion server/chat-plugins/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,9 @@ export const commands: ChatCommands = {
return this.add(this.tr("The poll timer was turned off."));
}
const timeout = parseFloat(target);
if (isNaN(timeout) || timeout <= 0 || timeout > Chat.MAX_TIMEOUT_DURATION) return this.errorReply(this.tr("Invalid time given."));
if (isNaN(timeout) || timeout <= 0 || timeout > Chat.MAX_TIMEOUT_DURATION) {
return this.errorReply(this.tr("Invalid time given."));
}
if (poll.timeout) clearTimeout(poll.timeout);
poll.timeoutMins = timeout;
poll.timeout = setTimeout(() => {
Expand Down
7 changes: 6 additions & 1 deletion server/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,12 @@ export const Chat = new class {
});
}
translationsLoaded = false;
readonly MAX_TIMEOUT_DURATION = 2147483647; // (2^32 / 2) - 1
/**
* As per the node.js documentation at https://nodejs.org/api/timers.html#timers_settimeout_callback_delay_args,
* timers with durations that are too long for a 32-bit signed integer will be invoked after 1 millisecond,
* which tends to cause unexpected behavior.
*/
readonly MAX_TIMEOUT_DURATION = 2147483647;

readonly multiLinePattern = new PatternTester();

Expand Down

0 comments on commit abe4409

Please sign in to comment.