Bug: outOfFocusTimeouts array grows unboundedly — cleared timeout ids never removed from array
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- frontend, performance
Direzione di ricerca
Inizia in frontend/src/ts/states/test.ts, dove viene popolato outOfFocusTimeouts, e analizza utils/misc.ts:148-153, dove clearTimeouts gestisce le voci. Traccia i chiamanti per confermare se cancellare tutti gli ID memorizzati o conservare solo l’ID più recente preserva il comportamento previsto di blur/refocus. Il lavoro è completato quando gli ID dei timeout cancellati non vengono più conservati e gli eventi ripetuti di unfocus/refocus non fanno più crescere l’array indefinitamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Did you clear cache before opening an issue?
- I have cleared my cache
Is there an existing issue for this?
- I have searched the existing open and closed issues
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@ 91bd24bb8
- Lingua principale
- TypeScript
- Stelle
- 20.7k
- Fork
- 3.3k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di monkeytypegame/monkeytype
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
monkeytypegame/monkeytype#8365 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
monkeytypegame/monkeytype#8364 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
monkeytypegame/monkeytype#8363 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
monkeytypegame/monkeytype#8362 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
monkeytypegame/monkeytype#8361 · 2 commenti ·
Tutte le issue di monkeytypegame/monkeytype
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
copse-dev/agent-pane#2953 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
[Bug]: Matrix progress drafts fail with "Matrix runtime not initialized" during tool activity Apertabug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
calcite-components needs triage refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Esri/calcite-design-system#15203 ·