mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Make reconnects smoother for dev servers (#12223)
Release Notes: - N/A Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
656edc4b2e
commit
3ec94697b4
@ -1140,8 +1140,17 @@ impl Server {
|
|||||||
Principal::DevServer(dev_server) => {
|
Principal::DevServer(dev_server) => {
|
||||||
{
|
{
|
||||||
let mut pool = self.connection_pool.lock();
|
let mut pool = self.connection_pool.lock();
|
||||||
if pool.dev_server_connection_id(dev_server.id).is_some() {
|
if let Some(stale_connection_id) = pool.dev_server_connection_id(dev_server.id)
|
||||||
return Err(anyhow!(ErrorCode::DevServerAlreadyOnline))?;
|
{
|
||||||
|
self.peer.send(
|
||||||
|
stale_connection_id,
|
||||||
|
proto::ShutdownDevServer {
|
||||||
|
reason: Some(
|
||||||
|
"another dev server connected with the same token".to_string(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
pool.remove_connection(stale_connection_id)?;
|
||||||
};
|
};
|
||||||
pool.add_dev_server(connection_id, dev_server.id, zed_version);
|
pool.add_dev_server(connection_id, dev_server.id, zed_version);
|
||||||
}
|
}
|
||||||
@ -2398,9 +2407,12 @@ async fn regenerate_dev_server_token(
|
|||||||
.dev_server_connection_id(dev_server_id);
|
.dev_server_connection_id(dev_server_id);
|
||||||
if let Some(connection_id) = connection_id {
|
if let Some(connection_id) = connection_id {
|
||||||
shutdown_dev_server_internal(dev_server_id, connection_id, &session).await?;
|
shutdown_dev_server_internal(dev_server_id, connection_id, &session).await?;
|
||||||
session
|
session.peer.send(
|
||||||
.peer
|
connection_id,
|
||||||
.send(connection_id, proto::ShutdownDevServer {})?;
|
proto::ShutdownDevServer {
|
||||||
|
reason: Some("dev server token was regenerated".to_string()),
|
||||||
|
},
|
||||||
|
)?;
|
||||||
let _ = remove_dev_server_connection(dev_server_id, &session).await;
|
let _ = remove_dev_server_connection(dev_server_id, &session).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2470,9 +2482,12 @@ async fn delete_dev_server(
|
|||||||
.dev_server_connection_id(dev_server_id);
|
.dev_server_connection_id(dev_server_id);
|
||||||
if let Some(connection_id) = connection_id {
|
if let Some(connection_id) = connection_id {
|
||||||
shutdown_dev_server_internal(dev_server_id, connection_id, &session).await?;
|
shutdown_dev_server_internal(dev_server_id, connection_id, &session).await?;
|
||||||
session
|
session.peer.send(
|
||||||
.peer
|
connection_id,
|
||||||
.send(connection_id, proto::ShutdownDevServer {})?;
|
proto::ShutdownDevServer {
|
||||||
|
reason: Some("dev server was deleted".to_string()),
|
||||||
|
},
|
||||||
|
)?;
|
||||||
let _ = remove_dev_server_connection(dev_server_id, &session).await;
|
let _ = remove_dev_server_connection(dev_server_id, &session).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,10 @@ impl DevServer {
|
|||||||
let request = if self.remote_shutdown {
|
let request = if self.remote_shutdown {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(self.client.request(proto::ShutdownDevServer {}))
|
Some(
|
||||||
|
self.client
|
||||||
|
.request(proto::ShutdownDevServer { reason: None }),
|
||||||
|
)
|
||||||
};
|
};
|
||||||
async move {
|
async move {
|
||||||
if let Some(request) = request {
|
if let Some(request) = request {
|
||||||
|
@ -510,6 +510,7 @@ message CreateDevServerResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message ShutdownDevServer {
|
message ShutdownDevServer {
|
||||||
|
optional string reason = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RenameDevServer {
|
message RenameDevServer {
|
||||||
|
Loading…
Reference in New Issue
Block a user