Gracefully continue if createStatusReportBase throws (#2225)

Previously, we weren't catching any possible exceptions in `createStatusReportBase` and runs would fail if any of the telemetry sub-items threw exceptions. As telemetry should not block the analysis, we continue here even if the status report throws.
This commit is contained in:
Angela P Wen 2024-04-04 15:26:14 -07:00 committed by GitHub
parent f421cda8e7
commit 7df281f2fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 505 additions and 418 deletions

View file

@ -34,16 +34,17 @@ async function run() {
let config: Config | undefined;
try {
await sendStatusReport(
await createStatusReportBase(
ActionName.ResolveEnvironment,
"starting",
startedAt,
config,
await checkDiskUsage(),
logger,
),
const statusReportBase = await createStatusReportBase(
ActionName.ResolveEnvironment,
"starting",
startedAt,
config,
await checkDiskUsage(),
logger,
);
if (statusReportBase !== undefined) {
await sendStatusReport(statusReportBase);
}
const gitHubVersion = await getGitHubVersion();
checkGitHubVersionInRange(gitHubVersion, logger);
@ -80,33 +81,35 @@ async function run() {
`Failed to resolve a build environment suitable for automatically building your code. ${error.message}`,
);
await sendStatusReport(
await createStatusReportBase(
ActionName.ResolveEnvironment,
getActionsStatus(error),
startedAt,
config,
await checkDiskUsage(),
logger,
error.message,
error.stack,
),
const statusReportBase = await createStatusReportBase(
ActionName.ResolveEnvironment,
getActionsStatus(error),
startedAt,
config,
await checkDiskUsage(),
logger,
error.message,
error.stack,
);
if (statusReportBase !== undefined) {
await sendStatusReport(statusReportBase);
}
}
return;
}
await sendStatusReport(
await createStatusReportBase(
ActionName.ResolveEnvironment,
"success",
startedAt,
config,
await checkDiskUsage(),
logger,
),
const statusReportBase = await createStatusReportBase(
ActionName.ResolveEnvironment,
"success",
startedAt,
config,
await checkDiskUsage(),
logger,
);
if (statusReportBase !== undefined) {
await sendStatusReport(statusReportBase);
}
}
async function runWrapper() {