-
Notifications
You must be signed in to change notification settings - Fork 184
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
fix: cancel pending requests as early as possible #2543
Conversation
self.session.cancel_request(self._document_diagnostic_pending_request.request_id) | ||
self._document_diagnostic_pending_request = None | ||
if self.semantic_tokens.pending_response: | ||
self.session.cancel_request(self.semantic_tokens.pending_response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have an urge to rename pending_response
to pending_request
.
pending_response
sounds like a boolean state (waiting for response) rather than what it actually is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking was that the request has already happened (was sent), so we're indeed only still waiting for the response now. But maybe we use the word "pending" in a sligthly different meaning. I guess it can both mean something like "upcoming" (that's how I used it here), or "unanswered". Of course the server response is directly coupled to the request, so feel free to rename it if you like to.
In that case I guess we don't need these parts anymore: Lines 489 to 492 in 04827c7
Lines 605 to 606 in 04827c7
Or is there maybe an edge case that I'm missing? |
I'd have to check. I thought that we still have to cancel but upon more thinking I've ruled out what I was thinking about before. |
Related issue: #1386 Should we set /**
* Client capability that signals how the client
* handles stale requests (e.g. a request
* for which the client will not process the response
* anymore since the information is outdated).
*
* @since 3.17.0
*/
staleRequestSupport?: {
/**
* The client will actively cancel the request.
*/
cancel: boolean;
/**
* The list of requests for which the client
* will retry the request if it receives a
* response with error code `ContentModified``
*/
retryOnContentModified: string[];
} |
I'm fine with that. I'm not sure what's the purpose of this capability though and whether it makes a difference that we don't consistently do canceling for every feature that could benefit from it. |
The only reference to I wonder if explicitly stating that we cancel requests would mean that we would potentially miss server canceling some requests that we don't currently cancel ourselves. |
LSP-vue (new volar version) does something that makes the cancel in
Summary
|
And since with pull diagnostics the server can also trigger Though that made me realize that ignoring a new request when the view version hasn't changed could in theory be incorrect if the server can return different diagnostics at different point in time (because it initialized late or something). That said, it might be a rare corner case. EDIT: added handling for that corner case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And since with pull diagnostics the server can also trigger workspace/diagnostic/refresh, in theory the same can happen with those.
Right, good that you thought of that.
I wonder whether ignore_pending
is the best name for this parameter, it's a bit difficult to understand in my opinion. Maybe something like forced
or forced_update
would be better?
On document change, it makes sense to cancel pending semantic tokens/pull diagnostics requests as early as possible rather than waiting for the debounce timeout and potentially failing to cancel request on time and wasting resources on handling those.