fix(process-daemon): block subscriptions instead of polling (#59698)

This commit is contained in:
James Long
2026-10-27 18:20:10 -04:00
committed by GitHub
Unverified
parent 5f394f64fc
commit f5cac1277c
2 changed files with 31 additions and 1 deletions
@@ -288,7 +288,6 @@ fn stream_subscription(
Ok(event) => event,
Err(_) => break Ok(()),
},
default(Duration::from_millis(100)) => continue,
};
let response = match event {
StreamEvent::Output { start, end, bytes } => {
@@ -277,6 +277,37 @@ fn subscription_delivers_final_exit_frame_before_closing() {
daemon.wait();
}
#[test]
fn shutdown_ends_an_idle_subscription() {
let mut daemon = Daemon::start();
let (mut owner, response) = daemon.own(None);
assert!(matches!(response, Response::Owned));
let terminal = daemon.terminal("exec cat");
let mut subscription = daemon.connect();
assert!(matches!(
daemon.send(
&mut subscription,
Request::Subscribe {
id: terminal.id,
offset: 0,
attachment_id: "idle-observer".into(),
role: AttachmentRole::Observer,
takeover: false,
}
),
Response::Attached { .. }
));
// The subscription is blocked with no output; shutdown must still end it.
assert!(matches!(
daemon.send(&mut owner, Request::Shutdown),
Response::Ok
));
// The 3s read timeout fails this read if the handler never closes the stream.
subscription.read_to_end(&mut Vec::new()).unwrap();
daemon.wait();
assert_terminal_stopped(&terminal);
}
#[test]
fn handoff_preserves_daemon_and_terminal_and_shutdown_overrides_it() {
let mut daemon = Daemon::start();