mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-27 12:22:49 +03:00
Introduce a timeout when processing incoming messages
We have an hypothesis that the server gets stuck while processing an incoming message, either because the buffer fills up or because a handler never completes. This should mitigate that and, once we add logging, give us some clue as to what is causing it exactly. Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
0b1fda3e13
commit
53a7f9c43e
@ -175,8 +175,10 @@ impl Peer {
|
||||
let incoming = incoming.context("received invalid RPC message")?;
|
||||
receive_timeout.set(create_timer(RECEIVE_TIMEOUT).fuse());
|
||||
if let proto::Message::Envelope(incoming) = incoming {
|
||||
if incoming_tx.send(incoming).await.is_err() {
|
||||
return Ok(());
|
||||
match incoming_tx.send(incoming).timeout(RECEIVE_TIMEOUT).await {
|
||||
Some(Ok(_)) => {},
|
||||
Some(Err(_)) => return Ok(()),
|
||||
None => Err(anyhow!("timed out processing incoming message"))?,
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user