Skip to content
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { sleep } from "../pure/time";
import { getErrorMessage } from "../pure/helpers-pure";
import { showAndLogWarningMessage } from "../helpers";
import { App } from "../common/app";
import { extLogger } from "../common";

export class VariantAnalysisMonitor extends DisposableObject {
// With a sleep of 5 seconds, the maximum number of attempts takes
Expand Down Expand Up @@ -41,6 +42,8 @@ export class VariantAnalysisMonitor extends DisposableObject {
let attemptCount = 0;
const scannedReposDownloaded: number[] = [];

let lastErrorShown: string | undefined = undefined;

while (attemptCount <= VariantAnalysisMonitor.maxAttemptCount) {
await sleep(VariantAnalysisMonitor.sleepTime);

Expand All @@ -56,13 +59,22 @@ export class VariantAnalysisMonitor extends DisposableObject {
variantAnalysis.id,
);
} catch (e) {
void showAndLogWarningMessage(
`Error while monitoring variant analysis ${
variantAnalysis.query.name
} (${variantAnalysis.query.language}) [${new Date(
variantAnalysis.executionStartTime,
).toLocaleString(env.language)}]: ${getErrorMessage(e)}`,
);
const errorMessage = getErrorMessage(e);

const message = `Error while monitoring variant analysis ${
Comment thread
koesie10 marked this conversation as resolved.
variantAnalysis.query.name
} (${variantAnalysis.query.language}) [${new Date(
variantAnalysis.executionStartTime,
).toLocaleString(env.language)}]: ${errorMessage}`;

// If we have already shown this error to the user, don't show it again.
if (lastErrorShown === errorMessage) {
void extLogger.log(message);
} else {
void showAndLogWarningMessage(message);
lastErrorShown = errorMessage;
}

continue;
}

Expand All @@ -84,6 +96,9 @@ export class VariantAnalysisMonitor extends DisposableObject {
}

attemptCount++;

// Reset the last error shown if we have successfully retrieved the variant analysis.
lastErrorShown = undefined;
}
}

Expand Down