Skip to content

Read-idle timeout on the agenticd connection loop #119

Closed

Description

@tonibergholm

Question

The carved-out slice of audit finding #5 (the rest is deferred to the backlog issue #118, decided on #109): give the connection read/dispatch/write loop a read-idle deadline so a peer that opens a socket and never completes a frame can't hold a spawn_local task forever.

Scope:

  • Apply a bounded read-idle timeout around read_frame_bytes in handle_connection (crates/agenticd/src/server.rs:140). On timeout, log (with peer_uid) and close the connection — the same log-and-close shape the FrameError::TooLarge arm already uses (no correlation_id available for a structured reply mid-frame).
  • Pick a generous default (a slow but legitimate first frame must not trip it); make it a const with a comment, tunable later.
  • The idle timeout resets per successful frame so a long-lived connection issuing well-spaced requests is unaffected.
  • Do NOT add connection/per-UID caps, rate budgets, or queue-depth metrics here — those are deferred to Socket availability hardening: connection caps, per-UID budgets, queue-depth metrics #118 by the Decide socket DoS budgets: fix in-map or defer #109 decision.

Tests: a peer that connects and sends nothing (or a partial frame) is dropped after the deadline; a peer sending well-spaced complete frames is not dropped.

Resolution records: PR link, the chosen timeout value, test names.

Activity

  1. added
    ready-for-agentScoped and unambiguous enough for an agent to pick up
    wayfinder:taskWayfinder ticket: work that unblocks a decision or lands a fix
    on Jul 9, 2026
  2. self-assigned this
    on Jul 10, 2026
  3. tonibergholm commented on Jul 10, 2026

    @tonibergholm
    MemberAuthor

    Resolution

    Shipped as PR #123 (pending review/merge).

    What landed: handle_connection wraps each read_frame_bytes in a per-frame READ_IDLE_TIMEOUT (30s); on elapse it log-and-closes with peer_uid (same shape as the oversize-frame arm). The clock resets per frame, so well-spaced-within-window connections are unaffected. Injected via handle_connection_with_idle_timeout so tests use a short deadline.

    Chosen value: 30s — generous enough that a slow legitimate first frame won't trip it; idle-beyond-window connections just reconnect (cheap over a Unix socket).

    Scope held: no connection/per-UID caps, rate budgets, or queue metrics — those stay in backlog #118 per the #109 decision.

    Tests: idle_connection_is_dropped_after_deadline (connect-and-send-nothing dropped with "idle" error), well_spaced_frames_are_not_dropped (Pings spaced within the window survive, clean close returns Ok). Both avoid tokio::spawn since the handler future isn't Send. Workspace tests + clippy + fmt green.

  4. added a commit that references this issue on Jul 10, 2026
    75c29de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ready-for-agentScoped and unambiguous enough for an agent to pick upwayfinder:taskWayfinder ticket: work that unblocks a decision or lands a fix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions