Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/process-daemon/src/daemon/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 } => {
Expand Down
31 changes: 31 additions & 0 deletions packages/process-daemon/tests/ownership.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading