Skip to content

Commit

Permalink
[flow] Flip default of experimental.libdef_recheck_partial_fix and …
Browse files Browse the repository at this point in the history
…remove ability to disable it

Summary: Changelog: [fix] When a library definition file has changed, Flow will no longer just stop the server. Instead, Flow will properly recheck everything, even under lazy mode.

Reviewed By: gkz

Differential Revision: D69870952

fbshipit-source-id: e00383c5112191ce49f66778318e5ca9692bb0ab
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Feb 19, 2025
1 parent 32c180b commit 782ecda
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 38 deletions.
1 change: 0 additions & 1 deletion src/commands/commandUtils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,6 @@ let make_options
gc_custom_minor_ratio = FlowConfig.gc_worker_custom_minor_ratio flowconfig;
gc_custom_minor_max_size = FlowConfig.gc_worker_custom_minor_max_size flowconfig;
};
opt_libdef_recheck_partial_fix = FlowConfig.libdef_recheck_partial_fix flowconfig;
opt_log_saving = FlowConfig.log_saving flowconfig;
opt_log_file;
opt_long_lived_workers =
Expand Down
11 changes: 6 additions & 5 deletions src/commands/config/flowConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ module Opts = struct
include_warnings: bool;
jest_integration: bool;
lazy_mode: lazy_mode option;
libdef_recheck_partial_fix: bool;
log_saving: Options.log_saving SMap.t;
long_lived_workers: bool;
max_files_checked_per_worker: int;
Expand Down Expand Up @@ -233,7 +232,6 @@ module Opts = struct
include_warnings = false;
jest_integration = false;
lazy_mode = None;
libdef_recheck_partial_fix = false;
log_saving = SMap.empty;
long_lived_workers = false;
max_files_checked_per_worker = 100;
Expand Down Expand Up @@ -1039,7 +1037,12 @@ module Opts = struct
("experimental.channel_mode", channel_mode_parser ~enabled:true);
("experimental.channel_mode.windows", channel_mode_parser ~enabled:Sys.win32);
( "experimental.libdef_recheck_partial_fix",
boolean (fun opts v -> Ok { opts with libdef_recheck_partial_fix = v })
boolean (fun opts v ->
if v then
Ok opts
else
Error "experimental.libdef_recheck_partial_fix cannot be disabled"
)
);
("experimental.long_lived_workers", long_lived_workers_parser ~enabled:true);
("experimental.long_lived_workers.windows", long_lived_workers_parser ~enabled:Sys.win32);
Expand Down Expand Up @@ -1798,8 +1801,6 @@ let jest_integration c = c.options.Opts.jest_integration

let lazy_mode c = c.options.Opts.lazy_mode

let libdef_recheck_partial_fix c = c.options.Opts.libdef_recheck_partial_fix

(* global defaults for lint severities and strict mode *)
let lint_severities c = c.lint_severities

Expand Down
2 changes: 0 additions & 2 deletions src/commands/config/flowConfig.mli
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ val jest_integration : config -> bool

val lazy_mode : config -> lazy_mode option

val libdef_recheck_partial_fix : config -> bool

(* global defaults for lint suppressions and strict mode *)
val lint_severities : config -> Severity.severity LintSettings.t

Expand Down
3 changes: 0 additions & 3 deletions src/common/options.ml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ type t = {
opt_include_suppressions: bool;
opt_include_warnings: bool;
opt_lazy_mode: bool;
opt_libdef_recheck_partial_fix: bool;
opt_lint_severities: Severity.severity LintSettings.t;
opt_log_file: File_path.t;
opt_log_saving: log_saving SMap.t;
Expand Down Expand Up @@ -278,8 +277,6 @@ let is_quiet opts = opts.opt_quiet

let lazy_mode opts = opts.opt_lazy_mode

let libdef_recheck_partial_fix opts = opts.opt_libdef_recheck_partial_fix

let lint_severities opts = opts.opt_lint_severities

let log_file opts = opts.opt_log_file
Expand Down
32 changes: 8 additions & 24 deletions src/server/rechecker/recheck_updates.ml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ let did_content_change ~reader filename =
let reader = Abstract_state_reader.State_reader reader in
not (Parsing_service_js.does_content_match_file_hash ~reader file content)

let check_for_lib_changes
~should_recover ~reader ~all_libs ~root ~skip_incompatible ~filter_wanted_updates updates =
let check_for_lib_changes ~reader ~all_libs ~root ~skip_incompatible ~filter_wanted_updates updates
=
let flow_typed_path = File_path.to_string (Files.get_flowtyped_path root) in
let is_changed_lib filename =
let is_lib = SSet.mem filename all_libs || filename = flow_typed_path in
Expand All @@ -153,20 +153,11 @@ let check_for_lib_changes
let messages =
SSet.elements libs |> List.rev_map (spf "Modified lib file: %s") |> String.concat "\n"
in
if should_recover then
let updates = filter_wanted_updates updates in
Error
(RecoverableShouldReinitNonLazily
{ msg = spf "%s\nLib files changed in an incompatible way" messages; updates }
)
else
Error
(Unrecoverable
{
msg = spf "%s\nLib files changed in an incompatible way" messages;
exit_status = Exit.Server_out_of_date;
}
)
let updates = filter_wanted_updates updates in
Error
(RecoverableShouldReinitNonLazily
{ msg = spf "%s\nLib files changed in an incompatible way" messages; updates }
)
else
Ok ()

Expand Down Expand Up @@ -232,14 +223,7 @@ let process_updates ?(skip_incompatible = false) ~options ~libs updates =
let filter_wanted_updates = filter_wanted_updates ~file_options ~sroot ~want in
(* Try to recover/die if libs files have changed *)
let%bind () =
check_for_lib_changes
~should_recover:(Options.libdef_recheck_partial_fix options)
~reader
~all_libs
~root
~skip_incompatible
~filter_wanted_updates
updates
check_for_lib_changes ~reader ~all_libs ~root ~skip_incompatible ~filter_wanted_updates updates
in
(* Return only the updates we care about *)
Ok (filter_wanted_updates updates)
1 change: 0 additions & 1 deletion tests/modified_lib/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ lib

[options]
all=true
experimental.libdef_recheck_partial_fix=true
1 change: 0 additions & 1 deletion tests/recheck/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ lib
[options]
all=true
exact_by_default=false
experimental.libdef_recheck_partial_fix=true
1 change: 0 additions & 1 deletion tests/recheck_while_full_check_reinit/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ lib
[options]
all=true
file_watcher=none
experimental.libdef_recheck_partial_fix=true

0 comments on commit 782ecda

Please sign in to comment.