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

Fix unhandled EPIPE error leading to language server crashes #478

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/lsp/Main.re
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ let showHelp = () => {
};

let main = () => {
Sys.set_signal(Sys.sigpipe, Sys.Signal_ignore);
switch (parseArgs(Sys.argv->Belt.List.fromArray)) {
| (opts, _) when opts->hasOpts(["-h", "--help"]) => showHelp();
| (opts, []) =>
Expand Down
2 changes: 1 addition & 1 deletion util/Commands.re
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let execFull = (~input=?, ~pwd=?, ~env=Unix.environment(), cmd) => {
| None => ()
| Some(text) => output_string(cmd_in, text)
};
close_out(cmd_in);
Copy link
Author

Choose a reason for hiding this comment

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

close_out would trigger a Sys_error("Broken pipe") exception now that we ignore the SIGPIPE signal. Instead of catching and handling it, we simply use close_out_noerr which ignores all errors

close_out_noerr(cmd_in);

let cmd_out_descr = Unix.descr_of_in_channel(cmd_out);
let cmd_err_descr = Unix.descr_of_in_channel(cmd_err);
Expand Down