Skip to content

Commit

Permalink
error streaming: show server progress the same way as without error s…
Browse files Browse the repository at this point in the history
…treaming

Summary:
With error streaming, currently hh shows a progress like "hh_server sync", instead of all the steps like "waiting for watchman", "computing files to recheck", etc.

With this diff, `hh` shows a server progress more interesting than "hh_server sync", by looking up the progress file.

Reviewed By: andrewjkennedy

Differential Revision: D66576201

fbshipit-source-id: 3b97972363630f4fe5055fa851b512edc070ca52
  • Loading branch information
Catherine Gasnier authored and facebook-github-bot committed Nov 29, 2024
1 parent 28ae0a8 commit e2db79b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions hphp/hack/src/client/clientCheckStatus.ml
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,7 @@ let go_streaming_on_fd
backtrace
in
progress_callback !latest_progress;
let error_count = ErrorsInfo.total_count errors_info in
update_partial_telemetry error_count;
update_partial_telemetry (ErrorsInfo.total_count errors_info);
consume errors_info printer)
in

Expand Down Expand Up @@ -545,6 +544,14 @@ end = struct
{ inode = stats.Unix.st_ino; ctime = stats.Unix.st_ctime }
end

let show_progress_and_sleep progress_callback =
let message =
try Some (Server_progress.read ()).Server_progress.message with
| _ -> None
in
Option.iter message ~f:(fun msg -> progress_callback (Some msg));
Lwt_unix.sleep 1.0

(** [keep_trying_to_open] tries to open the errors.bin file.
There is a whole load of ceremony to do with what happens when you want to open errors.bin,
e.g. start the server if necessary, check for version mismatch, report failures to the user.
Expand Down Expand Up @@ -626,7 +633,6 @@ let rec keep_trying_to_open
progress_callback None;
raise (Exit_status.Exit_with Exit_status.Out_of_time)
end);
progress_callback (Some "hh_server sync");
let fd_opt =
try
Some
Expand All @@ -651,7 +657,7 @@ let rec keep_trying_to_open
Lwt.return_unit
end else begin
(* Retry opening errors file every 0.1 second from now on. *)
let%lwt () = Lwt_unix.sleep 0.1 in
let%lwt () = show_progress_and_sleep progress_callback in
Lwt.return_unit
end
in
Expand All @@ -666,7 +672,7 @@ let rec keep_trying_to_open
let file_id = FileId.of_fd fd in
if Option.equal FileId.equal (Some file_id) already_checked_file then
(* we've already checked this file! so just wait a short time, then retry *)
let%lwt () = Lwt_unix.sleep 0.1 in
let%lwt () = show_progress_and_sleep progress_callback in
keep_trying_to_open
~has_already_attempted_connect
~connect_then_close
Expand Down Expand Up @@ -736,15 +742,13 @@ let rec keep_trying_to_open
(* Watchman doesn't support "what files have changed from error.bin's clock until
hh-invocation clock?". We'll instead use the (less permissive, still correct) query
"what files have changed from error.bin's clock until now?". *)
progress_callback (Some "watchman sync");
let%lwt since_result =
watchman_get_raw_updates_since
~root
~clock
~fail_on_new_instance:false
~fail_during_state:false
in
progress_callback (Some "hh_server sync");
match since_result with
| Error e ->
Hh_logger.log "Errors-file: watchman failure:\n%s\n" e;
Expand Down Expand Up @@ -788,7 +792,6 @@ let rec keep_trying_to_open
clock
(Relative_path.Set.cardinal updates)
(Relative_path.Set.choose updates |> Relative_path.suffix);
let%lwt () = Lwt_unix.sleep 0.1 in
keep_trying_to_open
~has_already_attempted_connect
~connect_then_close
Expand Down

0 comments on commit e2db79b

Please sign in to comment.