anomalyco / anomalyco/opencode

tui: resize listeners leak - repeated EventEmitter memory leak warnings on terminal resize

Open
#44,055 0 comments 0 reactions 1 assignee View on GitHub

@simonklee is already working on this.

Since Aug 22, 2026.

2.0
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

  1. Start the v2 TUI in Ghostty.
  2. Use it normally: switch tabs/sessions, resize the terminal window a few times, let agents run.
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.