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:
committed by
Facebook GitHub Bot
parent
6f9983eb42
commit
0510786dec
@@ -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
|
||||
? {
|
||||
|
||||
@@ -12,7 +12,7 @@ import {FlipperServer} from 'flipper-common';
|
||||
import {io, Socket} from 'socket.io-client';
|
||||
|
||||
const CONNECTION_TIMEOUT = 30 * 1000;
|
||||
const EXEC_TIMOUT = 30 * 10 * 1000;
|
||||
const EXEC_TIMOUT = 30 * 1000;
|
||||
|
||||
export function createFlipperServer(): Promise<FlipperServer> {
|
||||
// TODO: polish this all!
|
||||
@@ -54,6 +54,10 @@ export function createFlipperServer(): Promise<FlipperServer> {
|
||||
window?.flipperShowError?.('WebSocket connection lost');
|
||||
console.warn('Socket to Flipper server disconnected');
|
||||
connected = false;
|
||||
pendingRequests.forEach((r) =>
|
||||
r.reject(new Error('FLIPPER_SERVER_SOCKET_CONNECT_LOST')),
|
||||
);
|
||||
pendingRequests.clear();
|
||||
});
|
||||
|
||||
socket.on('exec-response', (id: number, data: any) => {
|
||||
|
||||
@@ -59,7 +59,7 @@ export function connectFlipperServerToStore(
|
||||
{'' + err}
|
||||
</>
|
||||
) : (
|
||||
<>Failed to start Flipper server: ${err.message}</>
|
||||
<>Failed to start Flipper server: {err.message ?? err}</>
|
||||
),
|
||||
duration: null,
|
||||
});
|
||||
|
||||
@@ -50,12 +50,21 @@ async function launchHealthchecks(options: HealthcheckOptions): Promise<void> {
|
||||
continue;
|
||||
}
|
||||
for (const h of category.healthchecks) {
|
||||
const checkResult = await flipperServer.exec(
|
||||
const checkResult: FlipperDoctor.HealthcheckResult = await flipperServer
|
||||
.exec(
|
||||
'doctor-run-healthcheck',
|
||||
{settings: options.settings},
|
||||
categoryKey as keyof FlipperDoctor.Healthchecks,
|
||||
h.key,
|
||||
);
|
||||
)
|
||||
.catch((e) => {
|
||||
console.error('Failed to run doctor check', e);
|
||||
return {
|
||||
status: 'FAILED',
|
||||
isAcknowledged: false,
|
||||
message: 'Failed to run doctor check: ' + e,
|
||||
};
|
||||
});
|
||||
const metricName = `doctor:${h.key.replace('.', ':')}.healthcheck`; // e.g. "doctor:ios:xcode-select.healthcheck"
|
||||
if (checkResult.status !== 'SUCCESS') {
|
||||
hasProblems = true;
|
||||
|
||||
Reference in New Issue
Block a user