Skip to content

fix(llm-proxy): guard health probe against ureq panic on early peer close - #4975

Open
CG-5228 wants to merge 1 commit into
rtk-ai:developfrom
CG-5228:fix/llm-proxy-probe-catch-unwind
Open

CG-5228 wants to merge 1 commit into
rtk-ai:developfrom
CG-5228:fix/llm-proxy-probe-catch-unwind

Conversation

@CG-5228

@CG-5228 CG-5228 commented Nov 3, 2026

Copy link
Copy Markdown

Summary

  • Wrap ureq::get(...).call() in llm_proxy::health_check_with_timeout with std::panic::catch_unwind, returning false if ureq panics while buffering a short response body (LimitedRead::read_exact(...).expect(...) in ureq 2.12.1 when a peer writes a response and closes the socket before reading the request on macOS).
  • Update hooks::session_start::probe_identity::probe_rejects_a_stranger_on_the_port to drain the incoming HTTP request before writing its stub response so the test exercises the identity check rather than racing socket close, and add probe_survives_peer_closing_without_reading_request to cover the early-close race directly.

Closes #4912

Test Plan

  • cargo test --lib hooks::session_start::probe_identity

@CLAassistant

CLAassistant commented Nov 3, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added area:proxy bug Something isn't working testing labels Nov 3, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes a panic in the llm-proxy health probe where ureq 2.12.1 could panic buffering a short response body if a peer replied and closed the socket before the request was read (a macOS-specific race). The fix wraps the ureq call in catch_unwind to return false instead of panicking, and updates/adds tests in probe_identity to cover the race.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4912


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

@aeppling aeppling left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @CG-5228, thanks for picking this up. Develop moved since you opened this: #4994 bumped ureq to 3, and the panic site this guards against (response.rs:401-403 in ureq 2.12.1) is gone. We reproduced the panic on your base (about 1% of early-close probes on macOS, with the same EINVAL as the issue) and saw none in 5,000 probes on develop, so the catch_unwind is no longer needed.

What's left from #4912 is the test half, which your PR already covers. The stub in probe_rejects_a_stranger_on_the_port still replies without reading the request, so the test can pass through a connection error instead of the identity check. Could you rebase on develop, drop the catch_unwind from llm_proxy.rs, and keep the two test changes (the stub that reads the request, and probe_survives_peer_closing_without_reading_request)? A test(llm-proxy): … title would then fit better, and it still closes #4912.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants