A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
fix(pa-daemon): match the TS error text for requests dropped by a dead worker (#3280)
Sebastian Müllerc6cf07bbe006
diff --git a/.changes/worker-socket-closed-error-text.md b/.changes/worker-socket-closed-error-text.mdnew file mode 100644index 0000000000..5f1a6cd5d6--- /dev/null+++ b/.changes/worker-socket-closed-error-text.md@@ -0,0 +1 @@+- A request that a crashed session worker never answered now fails with "Daemon worker socket closed", the same error the TypeScript daemon reports.diff --git a/crates/pa-daemon/src/supervisor/handshake_tests.rs b/crates/pa-daemon/src/supervisor/handshake_tests.rsindex c48bbebb38..3ee32de098 100644--- a/crates/pa-daemon/src/supervisor/handshake_tests.rs+++ b/crates/pa-daemon/src/supervisor/handshake_tests.rs@@ -432,5 +432,5 @@ async fn a_lost_worker_connection_fails_its_in_flight_route() {.expect("the lost connection fails the in-flight route").expect("the route task lives").expect_err("the drained route fails");- assert_eq!(error.to_string(), "Session worker dropped the request");+ assert_eq!(error.to_string(), super::routing::WORKER_SOCKET_CLOSED);}diff --git a/crates/pa-daemon/src/supervisor/routing.rs b/crates/pa-daemon/src/supervisor/routing.rsindex 8da2b5c339..4360f4771c 100644--- a/crates/pa-daemon/src/supervisor/routing.rs+++ b/crates/pa-daemon/src/supervisor/routing.rs@@ -21,6 +21,8 @@ pub(crate) const ROUTE_TIMEOUT_MS: u64 = 30_000;/// not leave the supervisor, so the replacement-aware route may retry it/// against the next connection without risking a duplicate landing.pub(crate) const WORKER_NOT_CONNECTED: &str = "Session worker is not connected";+/// TS daemon-worker-client.ts:98 reports this when the worker socket closes.+pub(crate) const WORKER_SOCKET_CLOSED: &str = "Daemon worker socket closed";/// Resolve a pending request whose frame provably never reached the worker/// (a failed frame write, or a request still queued when the writer pump@@ -204,7 +206,7 @@ impl Supervisor {Err(anyhow!(WORKER_NOT_CONNECTED))}Ok(Ok(reply)) => Ok(reply),- Ok(Err(_)) => Err(anyhow!("Session worker dropped the request")),+ Ok(Err(_)) => Err(anyhow!(WORKER_SOCKET_CLOSED)),Err(_) => {// A timed-out request's reply slot must not sit in the// pending map forever (a wedged worker never answers, anddiff --git a/crates/pa-daemon/src/supervisor/supervision.rs b/crates/pa-daemon/src/supervisor/supervision.rsindex b440c4df59..b4389b87ef 100644--- a/crates/pa-daemon/src/supervisor/supervision.rs+++ b/crates/pa-daemon/src/supervisor/supervision.rs@@ -1,6 +1,6 @@//! Worker supervision: the watch loop, the restart backoff, and//! the spawn/connect plumbing.-use super::routing::{fail_unsent_request, WORKER_REQUEST_TIMEOUT_MS};+use super::routing::{fail_unsent_request, WORKER_REQUEST_TIMEOUT_MS, WORKER_SOCKET_CLOSED};use super::{anyhow, connect_transport, create_command_payload, json, mpsc, persist_worker,persist_worker_at, probe_worker_socket, util, write_frame, Arc, Child, ClientRouting, Command,@@ -867,7 +867,7 @@ impl Supervisor {"Session worker timed out" => {format!("session worker {} did not come up in time", resident.worker_id)}- "Session worker dropped the request" => format!(+ WORKER_SOCKET_CLOSED => format!("session worker {} exited before its handshake finished",resident.worker_id),