{"record":{"id":"ac1739786592c9ed","repo":"getzola/zola","slug":"response-client-lock","errorCode":null,"errorMessage":"response client lock","messagePattern":"response client lock","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"components/templates/src/functions/load_data.rs","lineNumber":327,"sourceCode":"        let cache_key = data_source.get_cache_key(\n            &file_format,\n            method,\n            &post_body_arg,\n            &post_content_type,\n            &headers,\n        );\n\n        let mut cache = self.result_cache.lock().expect(\"result cache lock\");\n        if let Some(cached_result) = cache.get(&cache_key) {\n            return Ok(cached_result.clone());\n        }\n\n        let data = match data_source {\n            DataSource::Path(path) => read_file(&path).map_err(|e| {\n                Error::message(format!(\"`load_data`: error reading file {:?}: {}\", path, e))\n            }),\n            DataSource::Url(url) => {\n                let response_client = self.client.lock().expect(\"response client lock\");\n                let req = match method {\n                    Method::Get => response_client\n                        .get(url.as_str())\n                        .headers(add_headers_from_args(headers)?)\n                        .header(header::ACCEPT, file_format.as_accept_header()),\n                    Method::Post => {\n                        let mut resp = response_client\n                            .post(url.as_str())\n                            .headers(add_headers_from_args(headers)?)\n                            .header(header::ACCEPT, file_format.as_accept_header());\n                        if let Some(content_type) = post_content_type {\n                            match HeaderValue::from_str(&content_type) {\n                                Ok(c) => {\n                                    resp = resp.header(CONTENT_TYPE, c);\n                                }\n                                Err(_) => {\n                                    return Err(Error::message(format!(\n                                        \"`load_data`: {} is an illegal content type\",","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/components/templates/src/functions/load_data.rs#L309-L345","documentation":"When load_data fetches a URL, the shared reqwest client behind a Mutex is locked with .expect(\"response client lock\"). If the mutex was poisoned by a panic in another thread while performing a request, this call panics with a PoisonError message.","triggerScenarios":"A previous load_data URL request panicked while holding self.client (e.g. inside the request-building closure); the next remote-data call locks the poisoned mutex.","commonSituations":"Parallel template rendering of many remote loads where one thread panics (network/DNS panic path) and remaining renders cascade.","solutions":["Find and fix the original panic that poisoned the client mutex","Use .unwrap_or_else(|p| p.into_inner()) to tolerate poisoning","Store the reqwest Client without a Mutex (reqwest::Client is Arc internally and Sync) to eliminate the lock entirely"],"exampleFix":"// before\nlet response_client = self.client.lock().expect(\"response client lock\");\n// after\nlet response_client = self\n    .client\n    .lock()\n    .unwrap_or_else(|poisoned| poisoned.into_inner());","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let response_client = match self.client.lock() {\n    Ok(c) => c,\n    Err(poisoned) => poisoned.into_inner(),\n};","preventionTips":["reqwest::Client is cheap to clone and Sync; store it directly instead of behind a Mutex","Avoid panicking inside request-building code that runs while the lock is held","Treat any PoisonError as a symptom: find and fix the original panicking request"],"tags":["rust","mutex","poisoned-lock","panic","reqwest"],"backgroundTag":"mutex-lock-poisoned","analyzedSha":"61d30828217957120309db657950224edf9707e2","analyzedAt":"2026-09-03T14:39:09.727Z","contentChangedAt":"2026-09-03T14:39:09.727Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}