Skip to content

Commit 334cbd0

Browse files
authored
fixes unwrap on pid (#2657)
1 parent fdeb08d commit 334cbd0

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

crates/chat-cli/src/cli/chat/tool_manager.rs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,13 +1285,6 @@ fn spawn_orchestrator_task(
12851285
result,
12861286
pid,
12871287
} => {
1288-
let pid = pid.unwrap();
1289-
if !is_process_running(pid) {
1290-
info!(
1291-
"Received tool list result from {server_name} but its associated process {pid} is no longer running. Ignoring."
1292-
);
1293-
return;
1294-
}
12951288
let time_taken = loading_servers
12961289
.remove(&server_name)
12971290
.map_or("0.0".to_owned(), |init_time| {
@@ -1347,6 +1340,36 @@ fn spawn_orchestrator_task(
13471340

13481341
match result {
13491342
Ok(result) => {
1343+
if pid.is_none_or(|pid| !is_process_running(pid)) {
1344+
let pid = pid.map_or("unknown".to_string(), |pid| pid.to_string());
1345+
info!(
1346+
"Received tool list result from {server_name} but its associated process {pid} is no longer running. Ignoring."
1347+
);
1348+
1349+
let mut buf_writer = BufWriter::new(&mut *record_temp_buf);
1350+
let _ = queue_failure_message(
1351+
&server_name,
1352+
&eyre::eyre!("Process associated is no longer running"),
1353+
&time_taken,
1354+
&mut buf_writer,
1355+
);
1356+
let _ = buf_writer.flush();
1357+
drop(buf_writer);
1358+
let record_content = String::from_utf8_lossy(record_temp_buf).to_string();
1359+
let record = LoadingRecord::Err(record_content);
1360+
1361+
load_record
1362+
.lock()
1363+
.await
1364+
.entry(server_name.clone())
1365+
.and_modify(|load_record| {
1366+
load_record.push(record.clone());
1367+
})
1368+
.or_insert(vec![record]);
1369+
1370+
return;
1371+
}
1372+
13501373
let mut specs = result
13511374
.tools
13521375
.into_iter()

0 commit comments

Comments
 (0)