opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Memory leak: TUI and Slack bot event listeners not cleaned up

Open sauerdaniel opened this issue 19 hours ago • 1 comments

Problem

Several event listeners in the TUI and Slack bot are never cleaned up:

TUI Sync Context (sync.tsx)

The sdk.event.listen() call returns an unsubscribe function that is never called:

// Listener never cleaned up
sdk.event.listen((e) => { ... })

Tooltip Component (tooltip.tsx)

Mouse event listeners (mouseenter, mouseleave) are added to elements but never removed on component unmount, causing accumulation.

Slack Bot (slack/index.ts)

  • Sessions Map grows unbounded (no cleanup of old sessions)
  • No graceful shutdown handling (SIGINT/SIGTERM)
  • No limit on maximum concurrent sessions

Impact

  • Event listeners accumulate over component lifecycles
  • Sessions accumulate in Slack bot
  • Memory grows continuously in long-running processes

Relates to #5363

Expected Behavior

  • TUI event listeners should be unsubscribed in onCleanup
  • Tooltip should remove event listeners on unmount
  • Slack bot should clean up old sessions and handle shutdown

sauerdaniel avatar Jan 17 '26 23:01 sauerdaniel