You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Steps to reproduce the bug:
It's a countdown timer bug. Timer is using setTimeout function repeatedly from recursive function without checking if timeout was previously set. So if user inadvertently calls timerTick several times, for example, by quickly alternating between calls to resumeTimer and pauseTimer, he can set several timeouts running in parallel, resulting in an incorrect timer.
Related code:
It can be fixed in several ways, for example, current function
timerTick() {
setTimeout(() => {
...
});
}
can be changed into something like
timerTick() {
// this._timeoutHandle is null by default, so if it is not null now, means setTimeout()
// was previously called, and is now either executing or preparing to execute.
// By calling clearTimeout() in such case, we prevent another timerTick call chain
// running in another timeout callback.
if (this._timeoutHandle != null) {
clearTimeout(this._timeoutHandle);
this._timeoutHandle = null;
}
this._timeoutHandle = setTimeout(() => {
...
});
The text was updated successfully, but these errors were encountered:
I'm submitting a ...
[X] bug report
Steps to reproduce the bug:
It's a countdown timer bug. Timer is using
setTimeout
function repeatedly from recursive function without checking if timeout was previously set. So if user inadvertently callstimerTick
several times, for example, by quickly alternating between calls toresumeTimer
andpauseTimer
, he can set several timeouts running in parallel, resulting in an incorrect timer.Related code:
It can be fixed in several ways, for example, current function
can be changed into something like
The text was updated successfully, but these errors were encountered: