How worker-timers handles intervals and timeouts
masterUnlike native WindowTimers which use a single list for all timers, worker-timers maintains two separate internal lists: one for intervals and one for timeouts.
Important: You cannot use clearTimeout() to cancel an interval, nor can you use clearInterval() to cancel a timeout. Doing so will fail to cancel the intended timer because the IDs are stored in different lists.
const periodicWork = () => {};
// This will stop the interval.
const windowId = window.setInterval(periodicWork, 100);
window.clearTimeout(windowId);
// This will NOT cancel the interval. It may cancel a timeout instead.
const workerId = setInterval(periodicWork, 100);
clearTimeout(workerId);