Preserve ordering between responses and other incoming messages
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
d4fe1115e7
commit
8a2613d49c
5 changed files with 75 additions and 29 deletions
|
@ -59,6 +59,8 @@ features = ["runtime-async-std-rustls", "postgres", "time", "uuid"]
|
|||
collections = { path = "../collections", features = ["test-support"] }
|
||||
gpui = { path = "../gpui" }
|
||||
zed = { path = "../zed", features = ["test-support"] }
|
||||
ctor = "0.1"
|
||||
env_logger = "0.8"
|
||||
|
||||
lazy_static = "1.4"
|
||||
serde_json = { version = "1.0.64", features = ["preserve_order"] }
|
||||
|
|
|
@ -150,19 +150,20 @@ impl Server {
|
|||
message = next_message => {
|
||||
if let Some(message) = message {
|
||||
let start_time = Instant::now();
|
||||
log::info!("RPC message received: {}", message.payload_type_name());
|
||||
let type_name = message.payload_type_name();
|
||||
log::info!("rpc message received. connection:{}, type:{}", connection_id, type_name);
|
||||
if let Some(handler) = this.handlers.get(&message.payload_type_id()) {
|
||||
if let Err(err) = (handler)(this.clone(), message).await {
|
||||
log::error!("error handling message: {:?}", err);
|
||||
log::error!("rpc message error. connection:{}, type:{}, error:{:?}", connection_id, type_name, err);
|
||||
} else {
|
||||
log::info!("RPC message handled. duration:{:?}", start_time.elapsed());
|
||||
log::info!("rpc message handled. connection:{}, type:{}, duration:{:?}", connection_id, type_name, start_time.elapsed());
|
||||
}
|
||||
|
||||
if let Some(mut notifications) = this.notifications.clone() {
|
||||
let _ = notifications.send(()).await;
|
||||
}
|
||||
} else {
|
||||
log::warn!("unhandled message: {}", message.payload_type_name());
|
||||
log::warn!("unhandled message: {}", type_name);
|
||||
}
|
||||
} else {
|
||||
log::info!("rpc connection closed {:?}", addr);
|
||||
|
@ -1192,6 +1193,13 @@ mod tests {
|
|||
project::{DiagnosticSummary, Project, ProjectPath},
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
#[ctor::ctor]
|
||||
fn init_logger() {
|
||||
// std::env::set_var("RUST_LOG", "info");
|
||||
env_logger::init();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_share_project(mut cx_a: TestAppContext, mut cx_b: TestAppContext) {
|
||||
let (window_b, _) = cx_b.add_window(|_| EmptyView);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue