Repository navigation
Restore LSP request cancellation - #5172
Conversation
|
Tried this out and it fixes my case. I built HLS from this commit and ran three eval loops, then sent
Thanks for putting in the effort! <3 |
fendor
left a comment
There was a problem hiding this comment.
LGTM, some clarification questions
| cancelled <- atomically isCancelled | ||
| if cancelled | ||
| then onCancel |
There was a problem hiding this comment.
Why this initial check? This checks this is cancelled before we are starting to respond to the request.
Please add a comment, I imagine we are checking whether to even start the request if it had already been cancelled, but why only on startup, if we race them against each other?
There was a problem hiding this comment.
Good point, it's not worth it. Dropped
| -- This has to be masked, otherwise the handler might get cancelled after | ||
| -- the request was deleted from the pending set, causing us to forget to | ||
| -- send a response. | ||
| mask_ $ do | ||
| wasPending <- liftIO $ atomically $ removePendingRequest pending sid | ||
| when wasPending $ (runReaderT . unServerM) (resp r) st |
There was a problem hiding this comment.
Why would we ever not send a response?
Also, who might interrupt this?
There was a problem hiding this comment.
Also, who might interrupt this?
It would be waitForCancel that terminates this in-between the atomically . removePendingRequest and the when wasPending.
Why would we ever not send a response?
If a cancellation arrives between the above two lines. We end up removing the request from the pending request set, which is currently used as a signal to send a response.
In the other thread, as the request was cancelled, waitForCancel will proceed and check if it needs to respond with the cancellation response. But the request isn't in the pending set anymore.
Edit: Extended the comment to include this.
0159e51 to
d85dec1
Compare
d85dec1 to
7fba209
Compare
Closes #5171.
Supports
$/cancelRequestagain. This implements it as the following:Mapof pending ids.$/cancelRequest, flag that id in the map as cancelled.