Interrupt delayed websocket accept on shutdown

This commit is contained in:
starr-openai
2026-05-19 20:29:44 -07:00
parent 72ff0247e1
commit 372630049d
2 changed files with 8 additions and 5 deletions
+4 -1
View File
@@ -1246,7 +1246,10 @@ pub async fn start_websocket_server_with_headers(
};
if let Some(delay) = connection.accept_delay {
tokio::time::sleep(delay).await;
tokio::select! {
_ = &mut shutdown_rx => return,
_ = tokio::time::sleep(delay) => {}
}
}
let response_headers = connection.response_headers.clone();
@@ -649,8 +649,8 @@ async fn conversation_webrtc_start_posts_generated_session() -> Result<()> {
async fn conversation_webrtc_close_while_sideband_connecting_drops_pending_join() -> Result<()> {
skip_if_no_network!(Ok(()));
let sideband_accept_delay = Duration::from_millis(700);
let stale_sideband_observation_window = Duration::from_secs(1);
let sideband_accept_delay = Duration::from_secs(5);
let stale_sideband_observation_window = Duration::from_millis(700);
let server = start_mock_server().await;
Mock::given(method("POST"))
.and(path_regex(".*/realtime/calls$"))
@@ -664,8 +664,8 @@ async fn conversation_webrtc_close_while_sideband_connecting_drops_pending_join(
let realtime_server = start_websocket_server_with_headers(vec![WebSocketConnectionConfig {
requests: vec![vec![]],
response_headers: Vec::new(),
// Keep the sideband handshake pending through the close path on slow CI without adding a
// multi-second fixed tail when the mock websocket server shuts down.
// Keep the sideband handshake pending beyond the stale-event observation window below
// without adding a multi-second fixed tail when the mock websocket server shuts down.
accept_delay: Some(sideband_accept_delay),
close_after_requests: false,
}])