Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal: convert unwrap to except and add a debug log #15217

Merged
merged 1 commit into from Aug 8, 2023

Conversation

Sarrus1
Copy link
Contributor

@Sarrus1 Sarrus1 commented Jul 5, 2023

Remove an unsafe unwrap that can cause crashes if the value is a SendError.

This is my first PR on this repo, please let me know if there is anything I can improve or details I can provide.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 5, 2023
@Veykril
Copy link
Member

Veykril commented Jul 6, 2023

I believe this is intentional. The receiver for the given sender dropping before the server has properly exited smells like a bug by the consumer of lsp-server. The receiver shouldn't be dropped before.

@Veykril Veykril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 6, 2023
@Sarrus1
Copy link
Contributor Author

Sarrus1 commented Jul 6, 2023

It did seem intentional yes.

However, this has happened on multiple stable versions of VSCode as a receiver. I assume they implemented the protocol correctly.

Wouldn't it be better if this did not crash the server and logged an error instead ? Missing a notification does not seem fatal.

Is it possible for the receiver to be overwhelmed by the amount of notifications sent from the server? I imagine this would cause it to skip notifications and cause this error as well.

@Veykril
Copy link
Member

Veykril commented Jul 6, 2023

Wouldn't it be better if this did not crash the server and logged an error instead ? Missing a notification does not seem fatal.

Well, if the unwrap panics then that means the receiver has been dropped at which point no more messages can be sent over that channel anyways (no matter whether we panic or ignore the result).

Is it possible for the receiver to be overwhelmed by the amount of notifications sent from the server? I imagine this would cause it to skip notifications and cause this error as well.

The channel is created with a capacity of 0 meaning that any send operation will block until the receiver has received it.

@Sarrus1
Copy link
Contributor Author

Sarrus1 commented Jul 6, 2023

The channel is created with a capacity of 0 meaning that any send operation will block until the receiver has received it.

Ok ok so overwhelming the receiver is off the table.

no more messages can be sent over that channel anyways

Ah right so nothing can be done from this point, I see.

Thank you very much for answering my questions and looking into the PR!
I will try to better repro the issue to isolate the cause and report here if I find anything 👍

@lnicola
Copy link
Member

lnicola commented Jul 6, 2023

We could change it to an expect with an explanation of what happened, I suppose.

@Veykril
Copy link
Member

Veykril commented Aug 8, 2023

Can you remove the merge commit from the history here? Or just squash the commits into one

@Sarrus1 Sarrus1 reopened this Aug 8, 2023
@Sarrus1
Copy link
Contributor Author

Sarrus1 commented Aug 8, 2023

Sorry about that, should be all good now 👍

@Veykril Veykril changed the title fix: unsafe unwrap in lsp-server internal: Replace unwrap with expect in lsp-server Aug 8, 2023
@Veykril Veykril changed the title internal: Replace unwrap with expect in lsp-server internal: convert unwrap to except and add a debug log Aug 8, 2023
@Veykril
Copy link
Member

Veykril commented Aug 8, 2023

Thanks
@bors r+

@bors
Copy link
Collaborator

bors commented Aug 8, 2023

📌 Commit 02d5c0a has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Aug 8, 2023

⌛ Testing commit 02d5c0a with merge ed4e28b...

@bors
Copy link
Collaborator

bors commented Aug 8, 2023

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing ed4e28b to master...

@bors bors merged commit ed4e28b into rust-lang:master Aug 8, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants