Skip to content

Commit 0e32b4a

Browse files
fix: stop hanging indefinitely if process fails to start in memory executor
1 parent 8c239b5 commit 0e32b4a

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/executor/memory/executor.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use runner_shared::fifo::IntegrationMode;
2222
use std::path::Path;
2323
use std::rc::Rc;
2424
use tempfile::NamedTempFile;
25+
use tokio::time::{Duration, timeout};
2526

2627
const MEMTRACK_COMMAND: &str = "codspeed-memtrack";
2728
const MEMTRACK_CODSPEED_VERSION: &str = "1.0.0";
@@ -130,7 +131,16 @@ impl MemoryExecutor {
130131
debug!("handle_fifo called with PID {pid}");
131132

132133
// Accept the IPC connection from memtrack and get the sender it sends us
133-
let (_, memtrack_sender) = ipc.accept()?;
134+
// Use a timeout to prevent hanging if the process doesn't start properly
135+
// https://github.com/servo/ipc-channel/issues/261
136+
let (_, memtrack_sender) = timeout(Duration::from_secs(5), async move {
137+
tokio::task::spawn_blocking(move || ipc.accept())
138+
.await
139+
.context("Failed to spawn blocking task")?
140+
.context("Failed to accept IPC connection")
141+
})
142+
.await
143+
.context("Timeout waiting for IPC connection from memtrack process")??;
134144
let ipc_client = Rc::new(MemtrackIpcClient::from_accepted(memtrack_sender));
135145

136146
let ipc_client_health = Rc::clone(&ipc_client);

0 commit comments

Comments
 (0)