Skip to content

fix: solve #2961 — rate-limit terminal backpressure warnings#2962

Closed
github-actions[bot] wants to merge 1 commit into
mainfrom
triage/issue-2961-23671455629
Closed

fix: solve #2961 — rate-limit terminal backpressure warnings#2962
github-actions[bot] wants to merge 1 commit into
mainfrom
triage/issue-2961-23671455629

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Mar 27, 2026

Summary

  • Root cause: broadcastEvent() in the terminal host session logged a console.warn on every socket write that returned false (buffer full), with no rate limiting. Under sustained high-output (e.g. log tailing, bursty commands), a single pane could generate 400k+ identical warnings, flooding the daemon log.
  • Fix: Added rate-limited warning emission (BACKPRESSURE_WARN_INTERVAL_MS = 5000). Within each 5-second window, only the first warning is logged; subsequent occurrences are counted and reported in the next emitted warning (e.g. "... (247 similar warnings suppressed)").
  • The backpressure mechanism itself (pause/resume subprocess stdout) was already correct — only the warning logging was unbounded.

Test plan

  • Added test: first backpressure event emits a warning
  • Added test: 1000 rapid backpressure events emit only 1 warning (not 1000)
  • Added test: after the rate-limit window elapses, the next warning includes the suppressed count
  • All existing session tests continue to pass

Closes #2961


Summary by cubic

Rate-limit terminal backpressure warnings to stop log flooding during high-output sessions; only one warning is logged per 5 seconds, with suppressed counts reported in the next warning. Fixes #2961.

  • Bug Fixes
    • Emit at most one backpressure warning per session every 5s; accumulate and report suppressed count on the next warning.
    • Apply rate-limited warning when a client socket.write() returns false in broadcastEvent().
    • Keep existing backpressure handling (pause/resume stdout) unchanged.
    • Add tests for first warning, suppression within window, and suppressed count after the window.

Written for commit 361ec15. Summary will update on new commits.

The broadcastEvent() method logged a warning on every single socket
write that returned false, causing hundreds of thousands of identical
warnings under sustained high-output terminal sessions. Adds
rate-limiting (one warning per 5 seconds) with a suppressed-count
summary to keep logs useful without flooding.

Closes #2961
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Kitenite added a commit that referenced this pull request Mar 29, 2026
…limit warnings

Combines the fixes from #2969 and #2962 into a single changeset:

1. Skip writes to backpressured sockets (#2969): When a client socket
   signals backpressure (write returns false), subsequent broadcastEvent
   calls skip that socket entirely instead of growing Node's internal
   write buffer without bound. The terminal emulator still processes all
   data so snapshot state stays consistent — the next TUI repaint after
   drain naturally resyncs the display.

2. Rate-limit backpressure warnings (#2962): Replace unbounded
   console.warn on every backpressure event with a rate-limited
   warnBackpressure() method. Only one warning is emitted per 5-second
   window; subsequent occurrences are counted and reported in the next
   warning (e.g. '247 similar warnings suppressed'). Under sustained
   high-output commands, a single pane could previously generate 400k+
   identical warnings flooding the daemon log.

Tests cover: writes skipped during backpressure, writes resume after
drain, warning rate-limiting within the 5s window, and suppressed
count reporting after the window elapses.

Closes #2969
Closes #2962

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
Kitenite added a commit that referenced this pull request Mar 29, 2026
…limit warnings

Combines the fixes from #2969 and #2962 into a single changeset:

1. Skip writes to backpressured sockets (#2969): When a client socket
   signals backpressure (write returns false), subsequent broadcastEvent
   calls skip that socket entirely instead of growing Node's internal
   write buffer without bound. The terminal emulator still processes all
   data so snapshot state stays consistent — the next TUI repaint after
   drain naturally resyncs the display.

2. Rate-limit backpressure warnings (#2962): Replace unbounded
   console.warn on every backpressure event with a rate-limited
   warnBackpressure() method. Only one warning is emitted per 5-second
   window; subsequent occurrences are counted and reported in the next
   warning (e.g. '247 similar warnings suppressed'). Under sustained
   high-output commands, a single pane could previously generate 400k+
   identical warnings flooding the daemon log.

Tests cover: writes skipped during backpressure, writes resume after
drain, warning rate-limiting within the 5s window, and suppressed
count reporting after the window elapses.

Closes #2969
Closes #2962

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
@Kitenite Kitenite closed this in 8ff299c Mar 30, 2026
siarhei-belavus pushed a commit to siarhei-belavus/localset that referenced this pull request Mar 30, 2026
* fix(desktop): skip writes to backpressured terminal sockets and rate-limit warnings

Combines the fixes from superset-sh#2969 and superset-sh#2962 into a single changeset:

1. Skip writes to backpressured sockets (superset-sh#2969): When a client socket
   signals backpressure (write returns false), subsequent broadcastEvent
   calls skip that socket entirely instead of growing Node's internal
   write buffer without bound. The terminal emulator still processes all
   data so snapshot state stays consistent — the next TUI repaint after
   drain naturally resyncs the display.

2. Rate-limit backpressure warnings (superset-sh#2962): Replace unbounded
   console.warn on every backpressure event with a rate-limited
   warnBackpressure() method. Only one warning is emitted per 5-second
   window; subsequent occurrences are counted and reported in the next
   warning (e.g. '247 similar warnings suppressed'). Under sustained
   high-output commands, a single pane could previously generate 400k+
   identical warnings flooding the daemon log.

Tests cover: writes skipped during backpressure, writes resume after
drain, warning rate-limiting within the 5s window, and suppressed
count reporting after the window elapses.

Closes superset-sh#2969
Closes superset-sh#2962

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>

* fix(desktop): preserve terminal lifecycle events under backpressure

* fix(desktop): preserve terminal output under backpressure

* test(desktop): trim terminal host session coverage

* fix(desktop): remove terminal backpressure warning

---------

Co-authored-by: Mastra Code (anthropic/claude-opus-4-6) <noreply@mastra.ai>
(cherry picked from commit 8ff299c)
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.

[bug] high-output terminal panes can flood terminal-host with repeated "Client socket buffer full" warnings

0 participants