opencode
opencode copied to clipboard
Memory leak: TUI and Slack bot event listeners not cleaned up
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