show what it's working on, not [ready]
commit3a856c6c6d60899460395576f7c6cfa7f0cb2148
authorLucian Wischik <ljw@fb.com>
Thu, 15 Oct 2020 20:19:44 +0000 (15 13:19 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 15 Oct 2020 20:22:45 +0000 (15 13:22 -0700)
tree99e6e6adc58249246f3a5968590a2f62f1519668
parentff0b0b17e480396a61319eb24f2ce07c3cddd17a
show what it's working on, not [ready]

Summary:
A user reported, "hack says [ready] but it's not working".

More generally, I think the underlying user need is to have transparency about what hack is doing when it's not giving you your answers immediately.

To answer this holistically we need to think about the whole lifecycle of the server:
1. It starts with loading saved-state
2. Once ready, it calls ServerClientProvider.sleep_and_check. This waits for an incoming request, up to 1s. If the IDE was active then it might deny command-line requests. If no request arrived then it does a slice of GC collection and does idle processing.
3. It usually processes all outstanding disk changes at this point. Except, if IDE is active, or if it got interrupted, then it doesn't.
4. It handles the incoming request if there was one
5. And repeats from step 2

The current behavior:
* it shows [ready] at start of step 2
* it shows [typechecking] or similar message during the processing in step 3

The current behavior fails to convey some important user-relevant information, e.g. is it busy doing step 4 from some previous request? is a command-line request being denied because of IDE activity? It also misleading says "ready" when hh_server isn't ready, e.g. if it's got to first handle a lengthy step 4 from some previous request.

This diff is a step along the way to improvement. What it does do:
* No longer display "ready" at a misleading time
* Display information about an ongoing step 4
* Display if IDE is active

Reviewed By: dabek

Differential Revision: D24239724

fbshipit-source-id: a293c9f7dcf6658d7afe6dd66f32b8f5e29ce8ef
hphp/hack/src/server/serverCommand.ml
hphp/hack/src/server/serverCommandTypesUtils.ml
hphp/hack/src/server/serverMain.ml