ebkalderon / tower-lsp

Language Server Protocol implementation written in Rust
Apache License 2.0
952 stars 54 forks source link

Panic on future cancellation #417

Open s-panferov opened 2 months ago

s-panferov commented 2 months ago

Consider this scenario: we are invoking a request,

client.send_request::<MyRequest>(params).await?;

but the future that awaits it is getting cancelled and therefore the receiving end of the channel is getting dropped. Currently this would cause a panic with the "receiver already dropped" message. I believe it's coming from here:

tx.send(r).expect("receiver already dropped");

This is quite common situation and it feels like this code should not panic. Can the send error be safely ignored instead?

ebkalderon commented 2 months ago

I think that's reasonable enough. The code could simply be changed to swallow the Result with a simple let _ = assignment and not expecting on it.