Add catch-all error reporting for errors that slip through run

This commit is contained in:
Henry Mercer
2026-01-22 13:14:53 +00:00
parent 14bd76753f
commit 229e0cd749
17 changed files with 447 additions and 101 deletions
+11 -3
View File
@@ -64,6 +64,7 @@ import {
createStatusReportBase,
getActionsStatus,
sendStatusReport,
sendUnexpectedErrorStatusReport,
} from "./status-report";
import { ZstdAvailability } from "./tar";
import { ToolsDownloadStatusReport } from "./tools-download";
@@ -191,11 +192,10 @@ async function sendCompletedStatusReport(
}
}
async function run() {
async function run(startedAt: Date) {
// To capture errors appropriately, keep as much code within the try-catch as
// possible, and only use safe functions outside.
const startedAt = new Date();
const logger = getActionsLogger();
let apiDetails: GitHubApiCombinedDetails;
@@ -805,10 +805,18 @@ async function recordZstdAvailability(
}
async function runWrapper() {
const startedAt = new Date();
const logger = getActionsLogger();
try {
await run();
await run(startedAt);
} catch (error) {
core.setFailed(`init action failed: ${getErrorMessage(error)}`);
await sendUnexpectedErrorStatusReport(
ActionName.Init,
startedAt,
error,
logger,
);
}
await checkForTimeout();
}