Fixed relilability issues in running health checks

Summary: Run doctor checks remained pending when the socket disonnected during a check. This

Reviewed By: aigoncharov

Differential Revision: D32984539

fbshipit-source-id: 277005e78803afaaa220cc5ca7fdc9cca6254453
This commit is contained in:
Michel Weststrate
2021-12-13 05:46:42 -08:00
committed by Facebook GitHub Bot
parent 6f9983eb42
commit 0510786dec
4 changed files with 27 additions and 9 deletions

View File

@@ -42,6 +42,8 @@ export async function getHealthChecks(
});
}
let envInfoPromise: Promise<FlipperDoctor.EnvironmentInfo> | undefined;
export async function runHealthcheck(
options: FlipperDoctor.HealthcheckSettings,
categoryName: keyof FlipperDoctor.Healthchecks,
@@ -60,7 +62,10 @@ export async function runHealthcheck(
throw new Error('Unknown healthcheck: ' + ruleName);
}
const environmentInfo = await getEnvInfo();
if (!envInfoPromise) {
envInfoPromise = getEnvInfo();
}
const environmentInfo = await envInfoPromise;
const checkResult = await check.run!(environmentInfo, options.settings);
return checkResult.hasProblem && check.isRequired
? {