Did you clear cache before opening an issue?
Is there an existing issue for this?
Does the issue happen when logged in?
Yes
Does the issue happen when logged out?
Yes
Does the issue happen in incognito mode when logged in?
Yes
Does the issue happen in incognito mode when logged out?
Yes
Issue details
Current Behavior
outOfFocusTimeouts in frontend/src/ts/states/test.ts accumulates timeout ids forever:
// states/test.ts:38-54
const outOfFocusTimeouts: (number | NodeJS.Timeout)[] = [];
...
} else {
outOfFocusTimeouts.push(
setTimeout(() => { set(val); }, 1000),
);
}
Every unfocus event pushes a new id onto the array. clearTimeouts() (utils/misc.ts:148-153) only calls clearTimeout on each entry but never removes them from the array, so the array grows monotonically for the entire session. Long sessions with frequent alt-tabbing accumulate thousands of stale numeric ids (small but unnecessary retained memory, and the array scan in clearTimeouts grows linearly).
Expected Behavior
Remove consumed entries after clearing, e.g.:
export function clearTimeouts(timeouts: (number | NodeJS.Timeout)[]): void {
timeouts.forEach((to) => clearTimeout(to));
timeouts.length = 0;
}
or store only the latest timeout id, since scheduling a newer unfocus supersedes older pending ones anyway.
Steps To Reproduce
- Open devtools memory snapshot / add a breakpoint log on
outOfFocusTimeouts.push.
- Blur/refocus the window repeatedly during tests.
- Array length increases without bound and is never reset.
Environment
- OS: Any
- Browser: Any
- Found via source review of
master @ 91bd24b
Did you clear cache before opening an issue?
Is there an existing issue for this?
Does the issue happen when logged in?
Yes
Does the issue happen when logged out?
Yes
Does the issue happen in incognito mode when logged in?
Yes
Does the issue happen in incognito mode when logged out?
Yes
Issue details
Current Behavior
outOfFocusTimeoutsinfrontend/src/ts/states/test.tsaccumulates timeout ids forever:Every unfocus event pushes a new id onto the array.
clearTimeouts()(utils/misc.ts:148-153) only callsclearTimeouton each entry but never removes them from the array, so the array grows monotonically for the entire session. Long sessions with frequent alt-tabbing accumulate thousands of stale numeric ids (small but unnecessary retained memory, and the array scan inclearTimeoutsgrows linearly).Expected Behavior
Remove consumed entries after clearing, e.g.:
or store only the latest timeout id, since scheduling a newer unfocus supersedes older pending ones anyway.
Steps To Reproduce
outOfFocusTimeouts.push.Environment
master@ 91bd24b