Skip to content

fix: stop queuing stale screens for tui clients that stop reading - #6097

Merged
ogulcancelik merged 1 commit into
masterfrom
issue/5471-stalled-client-memory
Nov 19, 2026
Merged

ogulcancelik merged 1 commit into
masterfrom
issue/5471-stalled-client-memory

Conversation

@ogulcancelik

Copy link
Copy Markdown
Collaborator

refs #5471

when a connected tui client stops reading (a laptop asleep while attached over ssh), the server kept every screen update for it and its memory grew without bound (16 GB after a few days in the report). now only the latest pending screen state is kept for a client, so a stalled client costs a fixed amount and resumes normally when it wakes. notifications and other replies are still delivered in order. a 64 MiB per-client cap on that queue disconnects a client as a last resort.

reproduced on 0.9.5 and master on a linux box: a frozen client's server grew +0.57 MiB/min vs a normal one leveling off; with the fix both level off over 25 min, the frozen client resumes on the same connection with the right screen, and a slow client reading 75 MB of images isn't disconnected. no wire change. windows ci is red until #6093 lands (runner image); the new windows named-pipe test needs that run.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The client writer queue now limits retained control data to 64 MiB and disconnects the client stream when control data exceeds that limit. Pending state updates can replace unclaimed updates while preserving their position relative to reliable controls. The headless renderer sends projection, completion, and snapshot frames together through the state-update path. Tests cover ordering, overflow handling, transport-thread release, and render data outside the control-data limit.

Possibly related issues

  • Issue 5471 in herdrdev/herdr: The PR adds state coalescing and a per-client control-data cap, addressing the reported memory growth when a client stops reading its socket.

Suggested reviewers: akbash-bot

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 93360

This change bounds memory growth for stalled TUI clients by coalescing pending screen updates and disconnecting a client that exceeds a 64 MiB control-data cap. No actionable merge-blocking risk was found. Confirm that the Windows named-pipe test passes once the CI runner issue is resolved.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the server stops queuing stale screen updates for TUI clients that stop reading. The changeset matches this. The client writer queue now keeps only the latest pending …
Description check Passed The description states the problem (unbounded memory growth when a TUI client stops reading) and the fix (keeping only the latest pending screen state, plus a 64 MiB per-client cap). This matches the …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the server stops queuing stale screen updates for TUI clients that stop reading. The changeset matches this. The client writer queue now keeps only the latest pending screen state and adds a 64 MiB cap. The title is concise and specific.

Full details: Description check

Explanation

The description states the problem (unbounded memory growth when a TUI client stops reading) and the fix (keeping only the latest pending screen state, plus a 64 MiB per-client cap). This matches the changeset. It also gives reproduction results and a note on the Windows CI status.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7c6adc4e-dad0-49f4-a8e0-07756a039927
Commits

Reviewing files that changed from the base of the PR and between ee5bfb5 and 9336075.

Files selected for processing: 3

  • src/platform/windows.rs
  • src/server/client_transport.rs
  • src/server/headless/render.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@kangal-bot

Copy link
Copy Markdown
Collaborator

@coderabbitai review
@greptileai

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

This PR bounds each client's queued screen state while keeping notifications and replies in order.

  • Stalled TUI clients receive the newest pending shell state.
  • A client with an oversized control backlog is disconnected.

No actionable issues found. Tests were not run during this review. ogulcancelik reports that Windows CI is blocked by the runner image until #6093 lands; the new named-pipe test awaits that run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    S[Server updates] --> P[Latest pending screen state]
    C[Notifications and replies] --> Q[Ordered control queue]
    P --> W[Client writer]
    Q --> W
    R[Bounded render queue] --> W
    W --> T[Client connection]
    P --> B[Retained control byte count]
    Q --> B
    B -->|Over 64 MiB| D[Close connection]
Loading

Reviews (1) · Last reviewed commit: "fix: stop queuing stale screens for tui ..." · Reviewed by Greptile

@ogulcancelik
ogulcancelik merged commit 4898729 into master Nov 19, 2026
8 checks passed
@ogulcancelik
ogulcancelik deleted the issue/5471-stalled-client-memory branch November 19, 2026 20:39
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.

2 participants