the runtime your coding agents live on
Rust agentagent-orchestrationaiai-agentsclaude-codeclicodexcoding-agentsdeveloper-toolsdevtoolsmultiplexerrustterminalterminal-multiplexerterminal-uitmuxtuiworkspace-manager
fix(windows): bound queued Enter waits during pane shutdown (#4872)
JJ Liebigea8ed81b83ce
diff --git a/src/pty/actor.rs b/src/pty/actor.rsindex 19ce0bf9f..7c05fd7e9 100644--- a/src/pty/actor.rs+++ b/src/pty/actor.rs@@ -188,10 +188,10 @@ mod windows {.accepting.lock().unwrap_or_else(|poisoned| poisoned.into_inner());- // Pane shutdown terminates the child immediately after this returns. An Enter- // already queued must finish flushing, even if the async task cannot run.+ // Give a queued Enter the same grace as process termination. A blocked+ // pipe writer must not prevent teardown from terminating the child.if let Some(completion) = accepting.enter_completion.take() {- let _ = completion.recv();+ let _ = completion.recv_timeout(Duration::from_millis(250));}accepting.accepting = false;drop(accepting);@@ -725,8 +725,8 @@ mod windows {}#[test]- fn shutdown_waits_for_queued_enter_and_releases_when_writer_finishes_or_disconnects() {- for outcome in ["flushed", "failed", "disconnected"] {+ fn shutdown_gives_queued_enter_a_bounded_grace() {+ for outcome in ["flushed", "failed", "disconnected", "stalled"] {let runtime = test_runtime();let accepting = input_acceptance(true);let (data_tx, _data_rx) = mpsc::channel(1);@@ -755,6 +755,21 @@ mod windows {handle.shutdown();shutdown_done_tx.send(()).unwrap();});+ if outcome == "stalled" {+ // Keep the queued Enter and its completion sender alive until+ // shutdown returns, as a blocked pipe writer would do.+ let result = shutdown_done_rx.recv_timeout(Duration::from_secs(2));+ drop(command);+ shutdown.join().unwrap();+ assert!(result.is_ok(), "stalled Enter cannot prevent teardown");+ assert!(matches!(+ control_rx.try_recv(),+ Ok(PtyIoControlCommand::Shutdown)+ ));+ assert!(!accepting.lock().unwrap().accepting);+ assert!(runtime.block_on(input_task).unwrap().is_err());+ continue;+ }let deadline = Instant::now() + Duration::from_secs(2);while accepting.try_lock().is_ok() {assert!(Instant::now() < deadline, "shutdown takes acceptance lock");