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

Various fixes to progress handling #539

Merged
merged 10 commits into from
Jan 7, 2024
Merged

Various fixes to progress handling #539

merged 10 commits into from
Jan 7, 2024

Conversation

michaelpj
Copy link
Collaborator

  1. Server-initiated progress should wait for the client to acknowledge

This is an old bug. Per the spec, we're not allowed to send any reports using the token if the client doesn't respond with a non-error response to our creation of the token.

This is a bit subtle, because it means we may need to delay the sending of the "begin" notification until we have received the token from the client.

  1. No easy way to use client-initiated progress

This is simpler and faster than server-initiated progress since you don't need the extra message round-trip. You just need to pull out the progress token (if there is one) from the request and use that.

I did two things to make this better:

  • The progress functions now take the client token if there is one. If there isn't one they still fall back to server-initiated progress.
  • The server capabilities can now advertise that client-initiated progress is supported.

@michaelpj
Copy link
Collaborator Author

I'm actually unsure if we want to encourage people to use client-initiated progress, since I'm unsure if it allows cancelling properly: microsoft/language-server-protocol#1873

@michaelpj michaelpj force-pushed the mpj/fix-progress branch 2 times, most recently from 35e1fb4 to 785bb9e Compare December 29, 2023 21:15
@michaelpj
Copy link
Collaborator Author

Okay, I'm going to make it off by default since it's not clear how this will all work.

1. Server-initiated progress should wait for the client to acknowledge

This is an old bug. Per the spec, we're not allowed to send any reports
using the token if the client doesn't respond with a non-error response
to our creation of the token.

This is a bit subtle, because it means we may need to delay the sending
of the "begin" notification until we have received the token from the
client.

2. No easy way to use client-initiated progress

This is simpler and faster than server-initiated progress since you
don't need the extra message round-trip. You just need to pull out
the progress token (if there is one) from the request and use that.

I did two things to make this better:
- The progress functions now take the client token if there is one.
  If there isn't one they still fall back to server-initiated progress.
- The server capabilities can now advertise that client-initiated
  progress is supported.
Copy link
Collaborator

@joyfulmantis joyfulmantis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@michaelpj
Copy link
Collaborator Author

I added some more tests that actually exercise a bunch of the cases, so we can be a bit more confident that this works, hopefully.

@michaelpj michaelpj merged commit 242644d into master Jan 7, 2024
14 checks passed
soulomoon pushed a commit to soulomoon/lsp that referenced this pull request Apr 8, 2024
* Various fixes to progress handling

1. Server-initiated progress should wait for the client to acknowledge

This is an old bug. Per the spec, we're not allowed to send any reports
using the token if the client doesn't respond with a non-error response
to our creation of the token.

This is a bit subtle, because it means we may need to delay the sending
of the "begin" notification until we have received the token from the
client.

2. No easy way to use client-initiated progress

This is simpler and faster than server-initiated progress since you
don't need the extra message round-trip. You just need to pull out
the progress token (if there is one) from the request and use that.

I did two things to make this better:
- The progress functions now take the client token if there is one.
  If there isn't one they still fall back to server-initiated progress.
- The server capabilities can now advertise that client-initiated
  progress is supported.

* Make the default for client-initiated progress to be off

* Don't lose progress updates if it takes a while to start

* Refactor tests

* Add test for cancellation

* Fix minor bug in lsp-test config handling

* More tests

* Try this

* Fix formatting

* Add comment and purge traces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants