Memory leak: Footer component only clears last timeout in recursive chain #5401

Closed
opened 2026-02-16 17:52:17 -05:00 by yindo · 0 comments
Owner

Originally created by @sauerdaniel on GitHub (Jan 13, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

The Footer component uses a recursive setTimeout pattern for the welcome message animation, but only tracks the most recent timeout ID in a single variable.

function tick() {
  timeout = setTimeout(() => tick(), 5000)  // Overwrites previous ID
}
let timeout = setTimeout(() => tick(), 10_000)

onCleanup(() => {
  clearTimeout(timeout)  // Only clears the LAST timeout
})

When tick() schedules a new timeout, the previous timeout ID is lost before it can be cleared.

Impact

  • Earlier timeouts continue to fire after component unmount
  • Callbacks reference stale component state
  • Closures prevent garbage collection
  • Minor but cumulative memory leak

Location

packages/opencode/src/cli/cmd/tui/routes/session/footer.tsx - lines 27-47

Related

Part of #3013 (general memory issues)

Originally created by @sauerdaniel on GitHub (Jan 13, 2026). Originally assigned to: @rekram1-node on GitHub. ## Description The `Footer` component uses a recursive setTimeout pattern for the welcome message animation, but only tracks the most recent timeout ID in a single variable. ```typescript function tick() { timeout = setTimeout(() => tick(), 5000) // Overwrites previous ID } let timeout = setTimeout(() => tick(), 10_000) onCleanup(() => { clearTimeout(timeout) // Only clears the LAST timeout }) ``` When `tick()` schedules a new timeout, the previous timeout ID is lost before it can be cleared. ## Impact - Earlier timeouts continue to fire after component unmount - Callbacks reference stale component state - Closures prevent garbage collection - Minor but cumulative memory leak ## Location `packages/opencode/src/cli/cmd/tui/routes/session/footer.tsx` - lines 27-47 ## Related Part of #3013 (general memory issues)
yindo added the perf label 2026-02-16 17:52:17 -05:00
yindo closed this issue 2026-02-16 17:52:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#5401