Skip to content

Commit 4dcc8a9

Browse files
committed
Move failed status report code into sendFailedStatusReport
1 parent fbe3ae9 commit 4dcc8a9

File tree

3 files changed

+60
-44
lines changed

3 files changed

+60
-44
lines changed

lib/start-proxy-action.js

Lines changed: 21 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/start-proxy-action.ts

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,11 @@ import {
1515
getCredentials,
1616
getDownloadUrl,
1717
parseLanguage,
18+
sendFailedStatusReport,
1819
sendSuccessStatusReport,
1920
UPDATEJOB_PROXY,
2021
} from "./start-proxy";
21-
import {
22-
ActionName,
23-
createStatusReportBase,
24-
getActionsStatus,
25-
sendStatusReport,
26-
sendUnhandledErrorStatusReport,
27-
} from "./status-report";
22+
import { ActionName, sendUnhandledErrorStatusReport } from "./status-report";
2823
import * as util from "./util";
2924

3025
const KEY_SIZE = 2048;
@@ -152,25 +147,7 @@ async function run(startedAt: Date) {
152147
logger,
153148
);
154149
} catch (unwrappedError) {
155-
const error = util.wrapError(unwrappedError);
156-
core.setFailed(`start-proxy action failed: ${error.message}`);
157-
158-
// We skip sending the error message and stack trace here to avoid the possibility
159-
// of leaking any sensitive information into the telemetry.
160-
const errorStatusReportBase = await createStatusReportBase(
161-
ActionName.StartProxy,
162-
getActionsStatus(error),
163-
startedAt,
164-
{
165-
languages: language && [language],
166-
},
167-
await util.checkDiskUsage(logger),
168-
logger,
169-
"Error from start-proxy Action omitted",
170-
);
171-
if (errorStatusReportBase !== undefined) {
172-
await sendStatusReport(errorStatusReportBase);
173-
}
150+
await sendFailedStatusReport(logger, startedAt, language, unwrappedError);
174151
}
175152
}
176153

src/start-proxy.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Logger } from "./logging";
99
import {
1010
ActionName,
1111
createStatusReportBase,
12+
getActionsStatus,
1213
sendStatusReport,
1314
StatusReportBase,
1415
} from "./status-report";
@@ -52,6 +53,41 @@ export async function sendSuccessStatusReport(
5253
}
5354
}
5455

56+
/**
57+
* Sends a status report for the `start-proxy` action indicating a failure.
58+
*
59+
* @param logger The logger to use.
60+
* @param startedAt When the action was started.
61+
* @param language The language provided as input, if any.
62+
* @param unwrappedError The exception that was thrown.
63+
*/
64+
export async function sendFailedStatusReport(
65+
logger: Logger,
66+
startedAt: Date,
67+
language: KnownLanguage | undefined,
68+
unwrappedError: unknown,
69+
) {
70+
const error = util.wrapError(unwrappedError);
71+
core.setFailed(`start-proxy action failed: ${error.message}`);
72+
73+
// We skip sending the error message and stack trace here to avoid the possibility
74+
// of leaking any sensitive information into the telemetry.
75+
const errorStatusReportBase = await createStatusReportBase(
76+
ActionName.StartProxy,
77+
getActionsStatus(error),
78+
startedAt,
79+
{
80+
languages: language && [language],
81+
},
82+
await util.checkDiskUsage(logger),
83+
logger,
84+
"Error from start-proxy Action omitted",
85+
);
86+
if (errorStatusReportBase !== undefined) {
87+
await sendStatusReport(errorStatusReportBase);
88+
}
89+
}
90+
5591
export const UPDATEJOB_PROXY = "update-job-proxy";
5692
export const UPDATEJOB_PROXY_VERSION = "v2.0.20250624110901";
5793
const UPDATEJOB_PROXY_URL_PREFIX =

0 commit comments

Comments
 (0)