anomalyco / anomalyco/opencode
tui: resize listeners leak - repeated EventEmitter memory leak warnings on terminal resize
@simonklee is already working on this.
Since Aug 22, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
The TUI emits repeated Possible EventEmitter memory leak detected warnings for terminal resize listeners during normal use. Listener count keeps growing across resizes/tab switches instead of being cleaned up, so long-running sessions accumulate leaked listeners.
Environment
- opencode version: 0.0.0-beta-17498 (
@opencode-ai/cli@next) - OS: Linux 7.0.0-30-generic (x64)
- Terminal: Ghostty (TERM_PROGRAM=ghostty, COLORTERM=truecolor)
- Shell: zsh
- Install/channel: beta (npm next tag)
- Active plugins:
~/.config/opencode/plugins/herdr-agent-state.js,~/.config/opencode/plugins/moshi-hooks.ts
Reproduction
- Start the v2 TUI in Ghostty.
- Use it normally: switch tabs/sessions, resize the terminal window a few times, let agents run.
- Observe stderr/log output over time.
Expected Behavior
Resize listeners added by the renderer are removed when the render root/tab is torn down, or the emitter uses setMaxListeners; no warnings appear.
Actual Behavior
Repeated warnings, timestamped across a session:
[WARN] 'Possible EventEmitter memory leak detected. 11 resize listeners added to [Si]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit'
The [Si] target is a minified internal class (terminal/viewport object). Count stays pinned at "11" per burst but the warning re-fires continuously, suggesting listeners are added on every layout pass without removing previous ones.
Also seen once alongside it:
[WARN] 'Anchor is the same as the node box-29847 being inserted, skipping insertBefore'
Additional Context
- Happens intermittently but reproducibly; correlates with window resizes and tab activity (timestamps line up with resize moments).
- Warnings are non-fatal but grow noise in logs and indicate unbounded listener accumulation in long sessions.
- Possibly related: #28492 (MaxListenersExceededWarning after web interface starts) — different surface, same class of leak.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.