mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
Fix flakiness in WebSocket tests (#9169)
The connection was being added to the list after the WebSocket response was sent. So the test can sometimes race and observe connections before the list was updated. After this change, connection and request is added to the list before the response is sent.
This commit is contained in:
@@ -821,13 +821,20 @@ pub async fn start_websocket_server(connections: Vec<Vec<Vec<Value>>>) -> WebSoc
|
||||
continue;
|
||||
};
|
||||
|
||||
let mut connection_log = Vec::new();
|
||||
let connection_index = {
|
||||
let mut log = requests.lock().unwrap();
|
||||
log.push(Vec::new());
|
||||
log.len() - 1
|
||||
};
|
||||
for request_events in connection_requests {
|
||||
let Some(Ok(message)) = ws_stream.next().await else {
|
||||
break;
|
||||
};
|
||||
if let Some(body) = parse_ws_request_body(message) {
|
||||
connection_log.push(WebSocketRequest { body });
|
||||
let mut log = requests.lock().unwrap();
|
||||
if let Some(connection_log) = log.get_mut(connection_index) {
|
||||
connection_log.push(WebSocketRequest { body });
|
||||
}
|
||||
}
|
||||
|
||||
for event in &request_events {
|
||||
@@ -840,7 +847,6 @@ pub async fn start_websocket_server(connections: Vec<Vec<Vec<Value>>>) -> WebSoc
|
||||
}
|
||||
}
|
||||
|
||||
requests.lock().unwrap().push(connection_log);
|
||||
let _ = ws_stream.close(None).await;
|
||||
|
||||
if connections.lock().unwrap().is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user