Skip to content

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

Closed

Description

@MisterWanted

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: MaxListenersExceededWarning after web interface starts #28492 (MaxListenersExceededWarning after web interface starts) — different surface, same class of leak.

Activity

  1. alexxGmZ commented on Sep 30, 2026

    @alexxGmZ

    Based on my experience the memory leak happens only when the sidebar is open. If the sidebar is disabled, things are fine but the prompt box goes disappears unless the terminal is resized to it's state before the opencode is opened.

    Terminal: kitty v0.49.1
    opencode: v2.0.20

    watch the topbar displaying my memory

    opencode-memory-leak.mp4
  2. RawEnchilada commented on Oct 3, 2026

    @RawEnchilada

    Yeah this makes opencode not usable at all for me. If i resize the terminal even by accident my computer will freeze and i have to force kill via power button.

  3. simonklee commented on Oct 3, 2026

    @simonklee
    Member

    This is fixed in v2.0.21

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions