Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion ocaml-lsp-server/src/ocamlformat_rpc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,29 @@ let run_rpc ~logger ~bin t =
| Disabled | Stopped -> Fiber.return ()
| Running _ -> assert false
| Waiting_for_init _ ->
let* process = Process.create ~logger ~bin () in
let* process =
let* res = Fiber.collect_errors (fun () -> Process.create ~logger ~bin ()) in
match res with
| Ok process -> Fiber.return process
| Error exns ->
(* The ocamlformat-rpc process died or produced invalid output while
starting. Report it like a failed negotiation so that hover keeps
working with unformatted types instead of failing the request. *)
let message =
List.map exns ~f:(fun exn -> Printexc.to_string exn.exn)
|> String.concat ~sep:"; "
in
let* () =
logger
~type_:MessageType.Error
~message:
(Printf.sprintf
"An error happened when negotiating with the OCamlformat-RPC server: \
%s"
message)
in
Fiber.return (Error `No_process)
in
let* () = Fiber.Ivar.fill wait_init () in
(match process with
| Error `No_process ->
Expand Down
Loading