Skip to content

Commit 8917dfd

Browse files
sauerdanielfwang
authored andcommitted
fix(tui): track all timeouts in Footer to prevent memory leak (#8255)
1 parent 86900d7 commit 8917dfd

File tree

1 file changed

+7
-4
lines changed
  • packages/opencode/src/cli/cmd/tui/routes/session

1 file changed

+7
-4
lines changed

packages/opencode/src/cli/cmd/tui/routes/session/footer.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,27 @@ export function Footer() {
2525
})
2626

2727
onMount(() => {
28+
// Track all timeouts to ensure proper cleanup
29+
const timeouts: ReturnType<typeof setTimeout>[] = []
30+
2831
function tick() {
2932
if (connected()) return
3033
if (!store.welcome) {
3134
setStore("welcome", true)
32-
timeout = setTimeout(() => tick(), 5000)
35+
timeouts.push(setTimeout(() => tick(), 5000))
3336
return
3437
}
3538

3639
if (store.welcome) {
3740
setStore("welcome", false)
38-
timeout = setTimeout(() => tick(), 10_000)
41+
timeouts.push(setTimeout(() => tick(), 10_000))
3942
return
4043
}
4144
}
42-
let timeout = setTimeout(() => tick(), 10_000)
45+
timeouts.push(setTimeout(() => tick(), 10_000))
4346

4447
onCleanup(() => {
45-
clearTimeout(timeout)
48+
timeouts.forEach(clearTimeout)
4649
})
4750
})
4851

0 commit comments

Comments
 (0)