Ensure client reconnects after erroring during the handshake (#31278)

Release Notes:

- Fixed a bug that prevented Zed from reconnecting after erroring during
the initial handshake with the server.
This commit is contained in:
Antonio Scandurra 2025-05-23 15:46:30 +02:00 committed by GitHub
parent 03ac3fb91a
commit 9dba8e5b0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 79 additions and 14 deletions

View file

@ -61,6 +61,35 @@ fn init_logger() {
}
}
#[gpui::test(iterations = 10)]
async fn test_database_failure_during_client_reconnection(
executor: BackgroundExecutor,
cx: &mut TestAppContext,
) {
let mut server = TestServer::start(executor.clone()).await;
let client = server.create_client(cx, "user_a").await;
// Keep disconnecting the client until a database failure prevents it from
// reconnecting.
server.test_db.set_query_failure_probability(0.3);
loop {
server.disconnect_client(client.peer_id().unwrap());
executor.advance_clock(RECEIVE_TIMEOUT + RECONNECT_TIMEOUT);
if !client.status().borrow().is_connected() {
break;
}
}
// Make the database healthy again and ensure the client can finally connect.
server.test_db.set_query_failure_probability(0.);
executor.advance_clock(RECEIVE_TIMEOUT + RECONNECT_TIMEOUT);
assert!(
matches!(*client.status().borrow(), client::Status::Connected { .. }),
"status was {:?}",
*client.status().borrow()
);
}
#[gpui::test(iterations = 10)]
async fn test_basic_calls(
executor: BackgroundExecutor,