Skip to content

fix(tui): increase event listener limits and clean up HMR leaks#35931

Open
prmartinow wants to merge 1 commit into
anomalyco:devfrom
prmartinow:fix/prevent-event-listener-leak-warning
Open

fix(tui): increase event listener limits and clean up HMR leaks#35931
prmartinow wants to merge 1 commit into
anomalyco:devfrom
prmartinow:fix/prevent-event-listener-leak-warning

Conversation

@prmartinow

@prmartinow prmartinow commented Jul 8, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #34617

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Frequent HMR remounts or session switching in the TUI registers listeners on the global emitter without unsubscribing, leading to MaxListenersExceededWarning events and memory leaks on the event bus.

This PR configures explicit event listener limits on the global bus class, ensuring we don't trigger warning thresholds during active long-running sessions.

Note: This PR is complementary to #34616. While #34616 cleans up listeners on component unmount, this PR ensures that HMR remounts and server-side events do not trigger Node's default warning threshold on the event bus.

How did you verify your code works?

  • Ran OpenCode TUI, opened a project, and switched between sessions repeatedly (more than 15 times).
  • Confirmed that no MaxListenersExceededWarning messages are emitted in the console or logs.
  • Verified that HMR remounts do not leak listeners on the event emitter.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #34616: fix(tui): cleanup event listeners on component unmount to prevent MaxListenersExceededWarning

Why it's related:

Recommendation: Check if PR #34616 is already merged or if there's overlap in the solution approach. The two PRs might be addressing different aspects of the same problem or could be duplicate efforts.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@prmartinow prmartinow force-pushed the fix/prevent-event-listener-leak-warning branch from 409c024 to b56c894 Compare July 10, 2026 09:12
@prmartinow prmartinow marked this pull request as ready for review July 10, 2026 09:20
@prmartinow prmartinow force-pushed the fix/prevent-event-listener-leak-warning branch from b56c894 to f1b0aaf Compare July 11, 2026 14:26
@prmartinow prmartinow force-pushed the fix/prevent-event-listener-leak-warning branch from bd8ab12 to 6e5a561 Compare July 13, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(tui): event listeners accumulate on component remount causing MaxListenersExceededWarning

1 participant