{"record":{"id":"6995c3b4f06ac571","repo":"rust-lang/rust","slug":"operation-timed-out","errorCode":null,"errorMessage":"Operation Timed out","messagePattern":"Operation Timed out","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"library/std/src/sys/net/connection/uefi/tcp4.rs","lineNumber":339,"sourceCode":"    /// Wait for an event to finish. This is checked by an atomic boolean that is supposed to be set\n    /// to true in the event callback.\n    ///\n    /// Optionally, allow specifying a timeout.\n    ///\n    /// If a timeout is provided, the operation (specified by its `EFI_TCP4_COMPLETION_TOKEN`) is\n    /// canceled and Error of kind TimedOut is returned.\n    ///\n    /// # SAFETY\n    ///\n    /// Pointer to a valid `EFI_TCP4_COMPLETION_TOKEN`\n    unsafe fn wait_or_cancel(\n        &self,\n        timeout: Option<Duration>,\n        token: *mut tcp4::CompletionToken,\n    ) -> io::Result<()> {\n        if !self.wait_for_flag(timeout) {\n            let _ = unsafe { self.cancel(token) };\n            return Err(io::Error::new(io::ErrorKind::TimedOut, \"Operation Timed out\"));\n        }\n\n        Ok(())\n    }\n\n    /// Abort an asynchronous connection, listen, transmission or receive request.\n    ///\n    /// If token is NULL, then all pending tokens issued by EFI_TCP4_PROTOCOL.Connect(),\n    /// EFI_TCP4_PROTOCOL.Accept(), EFI_TCP4_PROTOCOL.Transmit() or EFI_TCP4_PROTOCOL.Receive() are\n    /// aborted.\n    ///\n    /// # SAFETY\n    ///\n    /// Pointer to a valid `EFI_TCP4_COMPLETION_TOKEN` or NULL\n    unsafe fn cancel(&self, token: *mut tcp4::CompletionToken) -> io::Result<()> {\n        let protocol = self.protocol.as_ptr();\n\n        let r = unsafe { ((*protocol).cancel)(protocol, token) };","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/library/std/src/sys/net/connection/uefi/tcp4.rs#L321-L357","documentation":"Returned by Rust std's UEFI TCP4 implementation in wait_or_cancel when wait_for_flag does not observe the completion flag within the supplied timeout. The implementation cancels the outstanding EFI_TCP4_COMPLETION_TOKEN and returns ErrorKind::TimedOut. UEFI networking is event-driven; this error means the asynchronous connect/transmit/receive never signalled completion in time.","triggerScenarios":"Calling TcpStream connect/read/write (or the underlying EFI TCP4 protocol wrappers) with a timeout on a UEFI application where the peer is unreachable, slow, or the network stack is misconfigured. wait_or_cancel receives Some(duration), polls wait_for_flag, and on timeout calls cancel(token) and returns the error.","commonSituations":"UEFI firmware network boot/diagnostic tool timing out against a missing DHCP/TFTP server; unreachable peer IP; firewall dropping packets; read/write timeout set lower than the remote response time.","solutions":["Increase the timeout passed to the connect/read/write operation.","Verify the UEFI network device driver is loaded and DHCP has assigned an address.","Confirm the peer address/port is correct and reachable from the firmware's network stack.","Handle ErrorKind::TimedOut explicitly to retry or degrade gracefully rather than aborting."],"exampleFix":"// before\nstream.set_read_timeout(Some(Duration::from_secs(1)))?;\nlet n = stream.read(&mut buf)?; // Operation Timed out\n\n// after\nstream.set_read_timeout(Some(Duration::from_secs(10)))?;\nmatch stream.read(&mut buf) {\n    Ok(n) => { /* use n */ }\n    Err(e) if e.kind() == io::ErrorKind::TimedOut => { /* retry / fallback */ }\n    Err(e) => return Err(e),\n}","handlingStrategy":"retry","validationCode":"fn sane_timeout(t: std::time::Duration) -> std::time::Duration {\n    t.max(std::time::Duration::from_secs(5))\n}\n// stream.set_read_timeout(Some(sane_timeout(configured)))?;","typeGuard":null,"tryCatchPattern":"match stream.read(&mut buf) {\n    Ok(n) => Ok(n),\n    Err(e) if e.kind() == io::ErrorKind::TimedOut => {\n        // optionally retry once, then degrade gracefully\n        Err(e)\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Verify the UEFI network device and DHCP lease before opening connections.","Size timeouts to the slowest expected remote response plus margin.","Handle ErrorKind::TimedOut explicitly instead of letting it abort the firmware app."],"tags":["rust","std","network","uefi","tcp","timeout","firmware"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}