Skip to content

Commit db0fc8b

Browse files
fix: stop hanging indefinitely if process fails to start in memory executor
1 parent 4817ea5 commit db0fc8b

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
@@ -18,6 +18,7 @@ use runner_shared::fifo::Command as FifoCommand;
1818
use runner_shared::fifo::IntegrationMode;
1919
use std::path::Path;
2020
use std::rc::Rc;
21+
use tokio::time::{Duration, timeout};
2122

2223
const MEMTRACK_COMMAND: &str = "codspeed-memtrack";
2324
const MEMTRACK_CODSPEED_VERSION: &str = "1.0.0";
@@ -120,7 +121,16 @@ impl MemoryExecutor {
120121
debug!("handle_fifo called with PID {pid}");
121122

122123
// Accept the IPC connection from memtrack and get the sender it sends us
123-
let (_, memtrack_sender) = ipc.accept()?;
124+
// Use a timeout to prevent hanging if the process doesn't start properly
125+
// https://github.com/servo/ipc-channel/issues/261
126+
let (_, memtrack_sender) = timeout(Duration::from_secs(5), async move {
127+
tokio::task::spawn_blocking(move || ipc.accept())
128+
.await
129+
.context("Failed to spawn blocking task")?
130+
.context("Failed to accept IPC connection")
131+
})
132+
.await
133+
.context("Timeout waiting for IPC connection from memtrack process")??;
124134
let ipc_client = Rc::new(MemtrackIpcClient::from_accepted(memtrack_sender));
125135

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

0 commit comments

Comments
 (0)