Skip to content

Commit e8ee43d

Browse files
committed
Suppress similar error messages when monitor MRVA
This will suppress showing the same error message when monitoring the variant analysis fails multiple times in a row. This is useful when e.g. the internet is disconnected or the endpoint is non-functional for any other reason. This will show the error message at least once, and then only show it if there has been a successful attempt in between or when the error message is different. This should result in a much less noisy experience.
1 parent 467e5ce commit e8ee43d

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

extensions/ql-vscode/src/variant-analysis/variant-analysis-monitor.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { sleep } from "../pure/time";
1414
import { getErrorMessage } from "../pure/helpers-pure";
1515
import { showAndLogWarningMessage } from "../helpers";
1616
import { App } from "../common/app";
17+
import { extLogger } from "../common";
1718

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

45+
let lastErrorShown: string | undefined = undefined;
46+
4447
while (attemptCount <= VariantAnalysisMonitor.maxAttemptCount) {
4548
await sleep(VariantAnalysisMonitor.sleepTime);
4649

@@ -56,13 +59,22 @@ export class VariantAnalysisMonitor extends DisposableObject {
5659
variantAnalysis.id,
5760
);
5861
} catch (e) {
59-
void showAndLogWarningMessage(
60-
`Error while monitoring variant analysis ${
61-
variantAnalysis.query.name
62-
} (${variantAnalysis.query.language}) [${new Date(
63-
variantAnalysis.executionStartTime,
64-
).toLocaleString(env.language)}]: ${getErrorMessage(e)}`,
65-
);
62+
const errorMessage = getErrorMessage(e);
63+
64+
const message = `Error while monitoring variant analysis ${
65+
variantAnalysis.query.name
66+
} (${variantAnalysis.query.language}) [${new Date(
67+
variantAnalysis.executionStartTime,
68+
).toLocaleString(env.language)}]: ${errorMessage}`;
69+
70+
// If we have already shown this error to the user, don't show it again.
71+
if (lastErrorShown === errorMessage) {
72+
void extLogger.log(message);
73+
} else {
74+
void showAndLogWarningMessage(message);
75+
lastErrorShown = errorMessage;
76+
}
77+
6678
continue;
6779
}
6880

@@ -84,6 +96,9 @@ export class VariantAnalysisMonitor extends DisposableObject {
8496
}
8597

8698
attemptCount++;
99+
100+
// Reset the last error shown if we have successfully retrieved the variant analysis.
101+
lastErrorShown = undefined;
87102
}
88103
}
89104

0 commit comments

Comments
 (0)