Record bounded session/channel close diagnostics on agent and gateway
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-17 12:57:09 +01:00
parent 932586ef33
commit 90689dafd1
2 changed files with 14 additions and 5 deletions
+11 -1
View File
@@ -2546,7 +2546,9 @@ fn service_run(stop: &'static AtomicBool) -> Result<()> {
continue;
}
let start = Instant::now();
let _ = agent.session(stop).await;
if let Err(error) = agent.session(stop).await {
record_session_error(&agent.config.state_directory, &error);
}
if start.elapsed() > Duration::from_secs(60) {
backoff = 1;
}
@@ -2611,6 +2613,14 @@ pub fn main() -> Result<()> {
rmm_agent_windows::service::dispatch(service_run)
}
/// Operator diagnostics only: the bounded error chain of the last session end
/// in the agent's own private state directory. Never authority or retry input.
fn record_session_error(state: &Path, error: &anyhow::Error) {
let mut text = format!("{error:#}");
text.truncate(1024);
let value = serde_json::json!({"schema_version":1,"observed_at_utc":Utc::now(),"error":text});
let _ = std::fs::write(state.join("session-last-error.json"), value.to_string());
}
#[cfg(test)]
mod tests {
use super::*;