{"record":{"id":"a28553555af33893","repo":"actix/actix-web","slug":"response-payload-io-timed-out","errorCode":null,"errorMessage":"Response Payload IO timed out","messagePattern":"Response Payload IO timed out","errorType":"exception","errorClass":"PayloadError","httpStatus":null,"severity":"error","filePath":"awc/src/responses/mod.rs","lineNumber":37,"sourceCode":"///\n/// See [`ClientResponse::_timeout`] for reason.\npub(crate) enum ResponseTimeout {\n    Disabled(Option<Pin<Box<Sleep>>>),\n    Enabled(Pin<Box<Sleep>>),\n}\n\nimpl Default for ResponseTimeout {\n    fn default() -> Self {\n        Self::Disabled(None)\n    }\n}\n\nimpl ResponseTimeout {\n    fn poll_timeout(&mut self, cx: &mut Context<'_>) -> Result<(), PayloadError> {\n        match *self {\n            Self::Enabled(ref mut timeout) => {\n                if timeout.as_mut().poll(cx).is_ready() {\n                    Err(PayloadError::Io(io::Error::new(\n                        io::ErrorKind::TimedOut,\n                        \"Response Payload IO timed out\",\n                    )))\n                } else {\n                    Ok(())\n                }\n            }\n            Self::Disabled(_) => Ok(()),\n        }\n    }\n}\n","sourceCodeStart":19,"sourceCodeEnd":49,"githubUrl":"https://github.com/actix/actix-web/blob/4d435abc281842f3cbee165b6cde739e001d3a25/awc/src/responses/mod.rs#L19-L49","documentation":"This is a runtime I/O error (`PayloadError::Io` with `ErrorKind::TimedOut`) raised when the client response body payload read exceeds the configured timeout. The `ResponseTimeout::poll_timeout` method at line 33-47 checks if the sleep timer has elapsed during body reading and returns this error to signal that the server took too long to send response data.","triggerScenarios":"Calling `.send()` on an awc client request and then reading the response body (e.g., `.body()`, `.json()`) when the server is slow to send body chunks. The timeout is set via `ClientRequest::timeout()` or the client's default configuration.","commonSituations":"Downloading large files from a slow server, server-side streaming endpoints that trickle data, or network issues causing stalls. Also common when the default timeout is too short for the workload.","solutions":["Increase or disable the response timeout: `client.get(url).timeout(Duration::from_secs(60)).send()`","Set a global client timeout when building the client: `Client::builder().timeout(Duration::from_secs(120)).finish()`","If the server is genuinely slow, consider streaming the body in chunks with explicit backpressure handling","Verify the server is not hanging or deadlocked — the timeout may be correctly catching a broken upstream"],"exampleFix":"// before\nlet mut resp = client.get(url).send().await?;\nlet body = resp.body().await?; // times out on slow server\n\n// after\nlet mut resp = client.get(url)\n    .timeout(Duration::from_secs(120))\n    .send().await?;\nlet body = resp.body().await?;","handlingStrategy":"try-catch","validationCode":"// Set an appropriate timeout based on expected response time.\n// For large/slow responses, increase or disable the timeout.\nlet resp = client.get(url)\n    .timeout(Duration::from_secs(120))\n    .send()\n    .await?;","typeGuard":null,"tryCatchPattern":"// Match on PayloadError to handle timeout gracefully.\nuse awc::error::SendRequestError;\n\nmatch client.get(url).timeout(Duration::from_secs(30)).send().await {\n    Ok(mut resp) => {\n        match resp.body().await {\n            Ok(body) => { /* process body */ }\n            Err(awc::error::PayloadError::Io(e)) if e.kind() == std::io::ErrorKind::TimedOut => {\n                // Handle timeout: retry, fallback, or return error\n                eprintln!(\"Response body timed out\");\n            }\n            Err(e) => { /* other payload error */ }\n        }\n    }\n    Err(e) => { /* connection or request error */ }\n}","preventionTips":["Set a generous timeout for slow endpoints: .timeout(Duration::from_secs(120))","Consider streaming large responses instead of reading the entire body at once","Monitor server response times to choose an appropriate timeout value","Implement retry logic with backoff for transient network slowness"],"tags":["rust","awc","http-client","runtime","timeout","network","io"],"backgroundTag":null,"analyzedSha":"4d435abc281842f3cbee165b6cde739e001d3a25","analyzedAt":"2026-08-09T01:01:40.926Z","contentChangedAt":"2026-08-09T01:01:40.926Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}