Skip to content

Commit 41725ab

Browse files
committed
Fixes
1 parent 4a8acce commit 41725ab

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

crates/observe/src/heap_dump_handler.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,19 @@ pub fn spawn_heap_dump_handler() {
3838
tracing::info!(socket = socket_path, "heap dump handler started");
3939

4040
let _ = tokio::fs::remove_file(&socket_path).await;
41+
let listener = match UnixListener::bind(&socket_path) {
42+
Ok(listener) => listener,
43+
Err(err) => {
44+
tracing::error!(
45+
?err,
46+
socket = socket_path,
47+
"failed to bind heap dump socket"
48+
);
49+
return;
50+
}
51+
};
4152
let handle = SocketHandle {
42-
listener: UnixListener::bind(&socket_path).expect("socket handle is unique"),
53+
listener,
4354
socket_path,
4455
};
4556

@@ -48,19 +59,20 @@ pub fn spawn_heap_dump_handler() {
4859
// Sequential processing prevents multiple simultaneous expensive heap dumps
4960
match handle.listener.accept().await {
5061
Ok((socket, _addr)) => {
51-
let handle = tokio::spawn(async move {
62+
let mut handle = tokio::spawn(async move {
5263
handle_connection_with_socket(socket).await;
5364
});
5465

5566
// 5-minute timeout to prevent stuck dumps from blocking future requests
56-
match timeout(Duration::from_secs(300), handle).await {
67+
match timeout(Duration::from_secs(300), &mut handle).await {
5768
Ok(Ok(())) => {
5869
// Task completed successfully
5970
}
6071
Ok(Err(err)) => {
6172
tracing::error!(?err, "panic in heap dump connection handler");
6273
}
6374
Err(_) => {
75+
handle.abort();
6476
tracing::error!("heap dump request timed out after 5 minutes");
6577
}
6678
}

0 commit comments

Comments
 (0)