Skip to content

Commit e99c3ad

Browse files
committed
fix: unblock event loop
1 parent 9aac335 commit e99c3ad

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/browser/daemon/server.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,12 @@ async fn handle_connection(
230230

231231
loop {
232232
line.clear();
233-
match reader.read_line(&mut line).await {
234-
Err(_) | Ok(0) => return ConnectionResult::Continue,
233+
// Bound the idle wait so the main select! loop can run health checks
234+
// and timers between commands. Current clients send one command per
235+
// connection and disconnect immediately, so 5 s is generous.
236+
match tokio::time::timeout(Duration::from_secs(5), reader.read_line(&mut line)).await {
237+
Err(_) => return ConnectionResult::Continue, // idle timeout
238+
Ok(Err(_)) | Ok(Ok(0)) => return ConnectionResult::Continue,
235239
Ok(_) => {
236240
let request: DaemonRequest = match serde_json::from_str(&line) {
237241
Ok(r) => r,

src/commands/browser/action.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,9 @@ pub async fn run(action: ActionCommand, session: Option<&str>) -> Result<()> {
11461146
let mut client = ensure_daemon(session).await?;
11471147

11481148
let result = dispatch_action(&mut client, action).await;
1149+
// Release the daemon connection before health-checking so the daemon's
1150+
// main loop can accept a new connection for the ping probe.
1151+
drop(client);
11491152
if let Err(ref err) = result {
11501153
// On failure, check if the remote session is still alive.
11511154
// If not, clear stale state and give a helpful error.

0 commit comments

Comments
 (0)