Skip to content

Commit

Permalink
fix never ending timer
Browse files Browse the repository at this point in the history
  • Loading branch information
splitice committed Sep 12, 2023
1 parent 0eff506 commit bf216d3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ function clearTimer(fn){
nextTimer = t
}
}
if(nextTimer === EmptyTimer){
clearTimeout(nextTickTimer)
nextTickTimer = null
}
} else {
timers.delete(fn)
}
Expand All @@ -305,7 +309,7 @@ function executeTimerTick(scheduled){
const workingTime = (now + scheduled) / 2

if(nextTimer.time > workingTime){
if(nextTickTimer !== EmptyTimer){
if(nextTimer !== EmptyTimer){
nextTickTimer = setTimeout(executeTimerTick, 25, Math.min(now + 25, workingTime + 50))
} else {
nextTickTimer = null
Expand Down

0 comments on commit bf216d3

Please sign in to comment.