Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

cloud_api_client: Add yield point to prevent background task hangs (#63105)

Remco Smits770aac345c76
diff --git a/Cargo.lock b/Cargo.lock
index 38d73288a29..bcb5c8012ab 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3215,6 +3215,7 @@ dependencies = [
"async-lock",
"cloud_api_types",
"futures 0.3.32",
+ "futures-lite 1.13.0",
"gpui",
"gpui_tokio",
"http_client",
diff --git a/crates/cloud_api_client/Cargo.toml b/crates/cloud_api_client/Cargo.toml
index 632cb9d5f35..4f8322063bc 100644
--- a/crates/cloud_api_client/Cargo.toml
+++ b/crates/cloud_api_client/Cargo.toml
@@ -14,6 +14,7 @@ path = "src/cloud_api_client.rs"
[dependencies]
anyhow.workspace = true
cloud_api_types.workspace = true
+futures-lite.workspace = true
futures.workspace = true
gpui.workspace = true
http_client.workspace = true
diff --git a/crates/cloud_api_client/src/websocket/native.rs b/crates/cloud_api_client/src/websocket/native.rs
index dd6a2396dac..e2d4b68aca7 100644
--- a/crates/cloud_api_client/src/websocket/native.rs
+++ b/crates/cloud_api_client/src/websocket/native.rs
@@ -5,6 +5,7 @@ use cloud_api_types::websocket_protocol::{PROTOCOL_VERSION, PROTOCOL_VERSION_HEA
use futures::channel::mpsc::unbounded;
use futures::stream::{SplitSink, SplitStream};
use futures::{FutureExt as _, SinkExt as _, StreamExt as _, TryStreamExt as _};
+use futures_lite::future::yield_now;
use gpui::{App, AppContext, Task};
use http_client::http::request;
use yawc::frame::Frame;
@@ -52,6 +53,8 @@ impl Connection {
}
}
}
+
+ yield_now().await;
}
});