Skip to content

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

@sauerdaniel

Description

@sauerdaniel

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)

Metadata

Metadata

Assignees

Labels

perfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions