{"record":{"id":"1c7e371c5220524c","repo":"xai-org/grok-build","slug":"connect-timed-out","errorCode":null,"errorMessage":"connect timed out","messagePattern":"connect timed out","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-fast-worktree/src/nfs/client.rs","lineNumber":632,"sourceCode":"            std::ptr::addr_of!(addr).cast::<libc::sockaddr>(),\n            addr_len,\n        )\n    };\n    if rc != 0 {\n        let err = std::io::Error::last_os_error();\n        if err.raw_os_error() != Some(libc::EINPROGRESS) {\n            return Err(err).context(\"connect\");\n        }\n        let mut pfd = libc::pollfd {\n            fd: raw,\n            events: libc::POLLOUT,\n            revents: 0,\n        };\n        let ms = i32::try_from(timeout.as_millis()).unwrap_or(i32::MAX);\n        // SAFETY: `pfd` is one pollfd we own for the duration of the call.\n        let pr = unsafe { libc::poll(std::ptr::addr_of_mut!(pfd), 1, ms) };\n        if pr == 0 {\n            return Err(std::io::Error::new(\n                std::io::ErrorKind::TimedOut,\n                \"connect timed out\",\n            ))\n            .context(\"connect\");\n        }\n        if pr < 0 {\n            return Err(std::io::Error::last_os_error()).context(\"poll\");\n        }\n        let mut so_err: libc::c_int = 0;\n        let mut len = std::mem::size_of::<libc::c_int>() as libc::socklen_t;\n        // SAFETY: `so_err`/`len` are valid stack integers; `raw` is our socket.\n        let gs = unsafe {\n            libc::getsockopt(\n                raw,\n                libc::SOL_SOCKET,\n                libc::SO_ERROR,\n                std::ptr::addr_of_mut!(so_err).cast(),\n                std::ptr::addr_of_mut!(len),","sourceCodeStart":614,"sourceCodeEnd":650,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-fast-worktree/src/nfs/client.rs#L614-L650","documentation":"In `connect_unix` of the NFS client, after `connect(2)` on a Unix domain socket returns EINPROGRESS, libc::poll waits up to `timeout` for the socket to become writable. A poll result of 0 means the timeout elapsed without the connection completing, so a TimedOut io::Error labeled 'connect timed out' is raised with a 'connect' context. It indicates the NFS daemon's socket never accepted the connection.","triggerScenarios":"Calling the NFS client (via `call`) when the daemon's unix socket exists but is not accepting: daemon hung or overloaded, backlog full, socket path stale, or the timeout is shorter than the daemon's response time.","commonSituations":"NFS worktree daemon crashed or was restarted while the socket file remains; system under heavy load so the daemon's event loop is stalled; connect_missing_socket_fails_quickly-style very small timeout used in production; container where the daemon isn't running.","solutions":["Check the daemon is alive and listening on the socket path (ls -l the socket, check daemon process/logs).","Remove a stale socket file and restart the daemon so a fresh one is bound.","Increase the connect timeout to tolerate loaded systems.","Fall back to the non-NFS (copy) worktree strategy on TimedOut, mirroring the StorageFull fallback path."],"exampleFix":"// before\nlet resp = nfs_client.call(req).await?;\n// after\nlet resp = nfs_client.call(req).await.unwrap_or_else(|e| {\n    tracing::warn!(%e, \"nfs daemon connect failed; falling back to copy\");\n    create_by_copy(req)\n});","handlingStrategy":"retry","validationCode":"let meta = std::fs::metadata(SOCKET_PATH)?; // socket must exist before connecting\nif !meta.file_type().is_socket() { anyhow::bail!(\"{} is not a socket\", SOCKET_PATH); }\n// plus a liveness probe of the daemon before the call","typeGuard":null,"tryCatchPattern":"match client.call(req).await {\n    Ok(resp) => resp,\n    Err(e) if e.to_string().contains(\"connect timed out\") => {\n        // short backoff, then fall back to copy strategy\n        tokio::time::sleep(Duration::from_millis(200)).await;\n        create_by_copy(req).await?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Health-check the NFS daemon (socket exists + responsive) before issuing calls","Remove stale socket files on daemon restart","Set a connect timeout that tolerates loaded systems","Monitor daemon liveness and restart it automatically when hung"],"tags":["network","ipc","unix-socket","timeout","nfs"],"backgroundTag":"connect-timed-out","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}