mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-28 20:01:33 +00:00
WIP: Start auditing all forward_request
calls on the server
When the host returns an error after a server has forwarded a request, we want to surface that error to the guest. At the moment, the server just returns early leaving some requests unresponded on the guest. I started auditing all the code paths where we do that, but I am wondering whether there's some other approach that would prevent us from repeating this mistake in other code paths.
This commit is contained in:
parent
2dbea2804c
commit
331667c00e
1 changed files with 55 additions and 15 deletions
|
@ -684,11 +684,19 @@ impl Server {
|
|||
|
||||
let sender = request.sender_id;
|
||||
let receipt = request.receipt();
|
||||
let response = self
|
||||
match self
|
||||
.peer
|
||||
.forward_request(sender, host, request.payload.clone())
|
||||
.await?;
|
||||
self.peer.respond(receipt, response)?;
|
||||
.await
|
||||
{
|
||||
Ok(response) => self.peer.respond(receipt, response)?,
|
||||
Err(error) => self.peer.respond_with_error(
|
||||
receipt,
|
||||
proto::Error {
|
||||
message: error.to_string(),
|
||||
},
|
||||
)?,
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -708,11 +716,19 @@ impl Server {
|
|||
|
||||
let sender = request.sender_id;
|
||||
let receipt = request.receipt();
|
||||
let response = self
|
||||
match self
|
||||
.peer
|
||||
.forward_request(sender, host, request.payload.clone())
|
||||
.await?;
|
||||
self.peer.respond(receipt, response)?;
|
||||
.await
|
||||
{
|
||||
Ok(response) => self.peer.respond(receipt, response)?,
|
||||
Err(error) => self.peer.respond_with_error(
|
||||
receipt,
|
||||
proto::Error {
|
||||
message: error.to_string(),
|
||||
},
|
||||
)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -731,11 +747,19 @@ impl Server {
|
|||
|
||||
let sender = request.sender_id;
|
||||
let receipt = request.receipt();
|
||||
let response = self
|
||||
match self
|
||||
.peer
|
||||
.forward_request(sender, host, request.payload.clone())
|
||||
.await?;
|
||||
self.peer.respond(receipt, response)?;
|
||||
.await
|
||||
{
|
||||
Ok(response) => self.peer.respond(receipt, response)?,
|
||||
Err(error) => self.peer.respond_with_error(
|
||||
receipt,
|
||||
proto::Error {
|
||||
message: error.to_string(),
|
||||
},
|
||||
)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -754,11 +778,19 @@ impl Server {
|
|||
|
||||
let sender = request.sender_id;
|
||||
let receipt = request.receipt();
|
||||
let response = self
|
||||
match self
|
||||
.peer
|
||||
.forward_request(sender, host, request.payload.clone())
|
||||
.await?;
|
||||
self.peer.respond(receipt, response)?;
|
||||
.await
|
||||
{
|
||||
Ok(response) => self.peer.respond(receipt, response)?,
|
||||
Err(error) => self.peer.respond_with_error(
|
||||
receipt,
|
||||
proto::Error {
|
||||
message: error.to_string(),
|
||||
},
|
||||
)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -777,11 +809,19 @@ impl Server {
|
|||
|
||||
let sender = request.sender_id;
|
||||
let receipt = request.receipt();
|
||||
let response = self
|
||||
match self
|
||||
.peer
|
||||
.forward_request(sender, host, request.payload.clone())
|
||||
.await?;
|
||||
self.peer.respond(receipt, response)?;
|
||||
.await
|
||||
{
|
||||
Ok(response) => self.peer.respond(receipt, response)?,
|
||||
Err(error) => self.peer.respond_with_error(
|
||||
receipt,
|
||||
proto::Error {
|
||||
message: error.to_string(),
|
||||
},
|
||||
)?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue