fix: solve #2961 — rate-limit terminal backpressure warnings#2962
Closed
github-actions[bot] wants to merge 1 commit into
Closed
fix: solve #2961 — rate-limit terminal backpressure warnings#2962github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
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
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>
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
broadcastEvent()in the terminal host session logged aconsole.warnon every socket write that returnedfalse(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.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)").Test plan
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.
socket.write()returns false inbroadcastEvent().Written for commit 361ec15. Summary will update on new commits.