Skip to content

Commit 2cd2583

Browse files
committed
fix: ignore hh_client output during extension init
We run `hh_client` once on extension startup before starting the LSP server because `hh_client --lsp` doesn't spawn `hh_server` if it's not running already (facebook/hhvm#8548). This can cause the extension to crash if there are a very large number of errors, as the output of `hh_client` won't fit into `maxBuffer`. Until we fix `hh_client --lsp`, let's simply instruct `hh_client` to return no errors here because we don't actually care about the output.
1 parent c6b14a2 commit 2cd2583

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/LSPHackTypeChecker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export class LSPHackTypeChecker {
4646
}),
4747
);
4848

49+
// `hh_client --lsp` fails to spawn `hh_server` if not already running,
50+
// so do an initial `hh_client` call to start the server if needed.
4951
await vscode.window.withProgress(
5052
{
5153
location: vscode.ProgressLocation.Window,

src/proxy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ export async function version(
1919
}
2020
}
2121

22+
/** Run `hh_client` to start `hh_server` if needed. */
2223
export async function start(
2324
config: HackConfig,
2425
log: vscode.LogOutputChannel,
2526
): Promise<string> {
26-
return run(config, log, []);
27+
// Ignore errors to avoid exceeding `maxBuffer` in case of many preexisting errors.
28+
// We only run this command to ensure `hh_server` starts and don't care about the output.
29+
return run(config, log, ["--max-errors", "0"]);
2730
}
2831

2932
async function run(

0 commit comments

Comments
 (0)