Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions lib/entry-points.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 27 additions & 19 deletions src/upload-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,10 @@
fs.writeFileSync(outputFile, sarifPayload);
}

const STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1000;
const STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1000;
// Should lead to status checks after 5s, 15s, 35s, 75s, and 155s.
const STATUS_CHECK_INITIAL_BACKOFF_MILLISECONDS = 5 * 1000;
const STATUS_CHECK_BACKOFF_MULTIPLIER = 2;
const STATUS_CHECK_MAX_TRIES = 5;

type ProcessingStatus = "pending" | "complete" | "failed";

Expand All @@ -854,20 +856,17 @@
try {
const client = api.getApiClient();

const statusCheckingStarted = Date.now();
while (true) {
if (
Date.now() >
statusCheckingStarted + STATUS_CHECK_TIMEOUT_MILLISECONDS
) {
// If the analysis hasn't finished processing in the allotted time, we continue anyway rather than failing.
// It's possible the analysis will eventually finish processing, but it's not worth spending more
// Actions time waiting.
logger.warning(
"Timed out waiting for analysis to finish processing. Continuing.",
);
break;
}
// Do an initial wait because processing will always take a minimum of 2-3 seconds
let statusCheckBackoff = STATUS_CHECK_INITIAL_BACKOFF_MILLISECONDS;
if (process.env["NODE_ENV"] !== "test") {

Check warning

Code scanning / CodeQL

Some environment variables may not exist in default setup workflows Warning

The environment variable NODE_ENV may not exist in default setup workflows. If all uses are safe, add it to the list of environment variables that are known to be safe in 'queries/default-setup-environment-variables.ql'. If this use is safe but others are not, dismiss this alert as a false positive.
await util.delay(statusCheckBackoff, { allowProcessExit: false });
}

for (
let statusCheckCount = 1;
statusCheckCount <= STATUS_CHECK_MAX_TRIES;
statusCheckCount++
) {
let response: OctokitResponse<any> | undefined = undefined;
try {
response = await client.request(
Expand Down Expand Up @@ -912,9 +911,18 @@
util.assertNever(status);
}

await util.delay(STATUS_CHECK_FREQUENCY_MILLISECONDS, {
allowProcessExit: false,
});
if (statusCheckCount === STATUS_CHECK_MAX_TRIES) {
// If the analysis hasn't finished processing in the allotted time, we continue anyway rather than failing.
// It's possible the analysis will eventually finish processing, but it's not worth spending more
// Actions time waiting.
logger.warning(
"Timed out waiting for analysis to finish processing. Continuing.",
);
break;
} else {
statusCheckBackoff *= STATUS_CHECK_BACKOFF_MULTIPLIER;
await util.delay(statusCheckBackoff, { allowProcessExit: false });
}
}
} finally {
logger.endGroup();
Expand Down
Loading