Skip to content

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

Closed

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)

Activity

  1. added
    perfIndicates a performance issue or need for optimization
    on Jan 13, 2026
  2. github-actions commented on Jan 13, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Both issues describe similar cleanup problems in TUI components where resources aren't properly released. Additionally, #3013 is the umbrella issue tracking general memory problems in opencode.

    Feel free to ignore if this doesn't address your specific case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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