Skip to content

Commit

Permalink
fix(lsp): wait for cancellation responses
Browse files Browse the repository at this point in the history
this is more spec complying

Signed-off-by: Rudi Grinberg <[email protected]>

ps-id: C29A2B64-D590-41EA-B93E-3BE361F24588
  • Loading branch information
rgrinberg committed Jun 13, 2022
1 parent 398c31e commit 7ee8f6b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lsp-fiber/src/rpc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,12 @@ struct
Fiber.Cancel.with_handler cancel
~on_cancel:(fun () -> on_cancel jsonrpc_req.id)
(fun () ->
let _, req_f =
Session.request_with_cancel (Fdecl.get t.session) jsonrpc_req
in
let+ resp = req_f in
match resp with
| `Cancelled -> `Cancelled
| `Ok resp -> `Ok (receive_response req resp))
let+ resp = Session.request (Fdecl.get t.session) jsonrpc_req in
match resp.result with
| Error { code = RequestCancelled; _ } -> `Cancelled
| Ok _ when Fiber.Cancel.fired cancel -> `Cancelled
| Ok s -> `Ok (Out_request.response_of_json req s)
| Error e -> raise (Jsonrpc.Response.Error.E e))
in
match cancel_status with
| Cancelled () -> `Cancelled
Expand Down

0 comments on commit 7ee8f6b

Please sign in to comment.