Skip to content

llm-proxy identity probe can panic inside ureq when the peer drops the connection #4912

Open

Description

@KuSh

hooks::session_start::probe_identity::probe_rejects_a_stranger_on_the_port failed on the macOS runner of PR #3833's CI (run 39525727363, job 118980201432). That PR touches only hooks/hermes/:

thread 'hooks::session_start::probe_identity::probe_rejects_a_stranger_on_the_port' panicked at
.../ureq-2.12.1/src/response.rs:403:34:
failed to read exact buffer length from stream: Os { code: 22, kind: InvalidInput, message: "Invalid argument" }

The test calls the production probe() (src/hooks/session_start.rs:82, which calls crate::llm_proxy::is_rtk_proxy_at) against a stub server. The stub writes HTTP/1.1 200 OK … {} and drops the socket without reading the request. ureq 2.12.1 buffers a short body with read_exact(...).expect(...) (response.rs:401-403). Its own comment there says this can panic when resetting the stream's timeouts fails. On macOS, the reset after an unread request turns that into a panic.

So it is not only a flaky test. Anything listening on the probed port that answers and closes early can make the probe panic instead of returning false. The test exists because a stranger on the port is the expected case (8080 is a common dev-server port).

Two parts to a fix:

  • the probe must not unwind: catch the panic around the ureq call, or read the body without ureq's buffered expect path;
  • the test stub should read the request before replying, so the test checks the identity decision rather than the socket race.

Develop's own CI runs have passed this test on macOS, so it is intermittent.

Activity

  1. rtk-wshm-sync-bot commented on Nov 1, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 90%

    Summary

    ureq panics instead of returning false when a peer on the probed port drops the connection early; probe needs panic isolation and the test stub needs to read the request first.

    📁 Relevant files
    • src/hooks/session_start.rs
    • src/llm_proxy.rs

    Suggested Actions

    1. Wrap the ureq call in src/llm_proxy.rs (is_rtk_proxy_at) with catch_unwind or avoid the buffered read_exact path
    2. Fix the test stub in session_start.rs's probe_rejects_a_stranger_on_the_port to read the request before responding
    3. Check ureq 2.12.1 changelog/issue tracker for known read_exact panic on timeout-reset failure
    4. Re-run PR fix(hermes): close the rewrite's stdin and make its timeout configurable #3833's macOS CI job (39525727363/118980201432) after the fix to confirm stability

    Triaged automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions