fix: add 10s timeout to post_result to prevent hung API calls

This commit is contained in:
M1 2026-03-18 13:24:52 +04:00
parent 3ce89a88bf
commit 5037222846
1 changed files with 10 additions and 6 deletions

View File

@ -342,11 +342,15 @@ async fn post_result(
token: &str, token: &str,
result: PingResult, result: PingResult,
) -> Result<()> { ) -> Result<()> {
tokio::time::timeout(
std::time::Duration::from_secs(10),
client client
.post(format!("{coordinator_url}/internal/ingest")) .post(format!("{coordinator_url}/internal/ingest"))
.header("x-monitor-token", token) .header("x-monitor-token", token)
.json(&result) .json(&result)
.send() .send()
.await?; ).await
.map_err(|_| anyhow::anyhow!("post_result timed out"))?
.map_err(|e| anyhow::anyhow!("{e}"))?;
Ok(()) Ok(())
} }