Improve logging when there is an error in the RPC layer
Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
parent
d0660f41de
commit
024684e46c
2 changed files with 15 additions and 3 deletions
|
@ -113,7 +113,13 @@ impl Client {
|
||||||
async_tungstenite::client_async(format!("wss://{}/rpc", host), stream).await?;
|
async_tungstenite::client_async(format!("wss://{}/rpc", host), stream).await?;
|
||||||
log::info!("connected to rpc address {}", &*ZED_SERVER_URL);
|
log::info!("connected to rpc address {}", &*ZED_SERVER_URL);
|
||||||
let (connection_id, handler) = self.peer.add_connection(stream).await;
|
let (connection_id, handler) = self.peer.add_connection(stream).await;
|
||||||
executor.spawn(handler.run()).detach();
|
executor
|
||||||
|
.spawn(async move {
|
||||||
|
if let Err(error) = handler.run().await {
|
||||||
|
log::error!("connection error: {:?}", error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
connection_id
|
connection_id
|
||||||
} else if let Some(host) = server_url.strip_prefix("http://") {
|
} else if let Some(host) = server_url.strip_prefix("http://") {
|
||||||
let stream = smol::net::TcpStream::connect(host).await?;
|
let stream = smol::net::TcpStream::connect(host).await?;
|
||||||
|
@ -121,7 +127,13 @@ impl Client {
|
||||||
async_tungstenite::client_async(format!("ws://{}/rpc", host), stream).await?;
|
async_tungstenite::client_async(format!("ws://{}/rpc", host), stream).await?;
|
||||||
log::info!("connected to rpc address {}", &*ZED_SERVER_URL);
|
log::info!("connected to rpc address {}", &*ZED_SERVER_URL);
|
||||||
let (connection_id, handler) = self.peer.add_connection(stream).await;
|
let (connection_id, handler) = self.peer.add_connection(stream).await;
|
||||||
executor.spawn(handler.run()).detach();
|
executor
|
||||||
|
.spawn(async move {
|
||||||
|
if let Err(error) = handler.run().await {
|
||||||
|
log::error!("connection error: {:?}", error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
connection_id
|
connection_id
|
||||||
} else {
|
} else {
|
||||||
return Err(anyhow!("invalid server url: {}", server_url))?;
|
return Err(anyhow!("invalid server url: {}", server_url))?;
|
||||||
|
|
|
@ -705,7 +705,7 @@ impl Workspace {
|
||||||
|
|
||||||
cx.spawn(|_, _| async move {
|
cx.spawn(|_, _| async move {
|
||||||
if let Err(e) = task.await {
|
if let Err(e) = task.await {
|
||||||
log::error!("sharing failed: {}", e);
|
log::error!("sharing failed: {:?}", e);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue