Skip to content

Commit 619c485

Browse files
authored
Show query results before structured evaluator log summary completes (#1350)
1 parent 9367d5f commit 619c485

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

extensions/ql-vscode/src/query-history.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,13 +812,16 @@ export class QueryHistoryManager extends DisposableObject {
812812
}
813813

814814
private warnNoEvalLog() {
815-
void showAndLogWarningMessage('No evaluator log is available for this run. Perhaps it failed before evaluation, or you are running with a version of CodeQL before ' + CliVersionConstraint.CLI_VERSION_WITH_PER_QUERY_EVAL_LOG + '?');
815+
void showAndLogWarningMessage(`No evaluator log is available for this run. Perhaps it failed before evaluation, or you are running with a version of CodeQL before ' + ${CliVersionConstraint.CLI_VERSION_WITH_PER_QUERY_EVAL_LOG}?`);
816816
}
817817

818818
private warnNoEvalLogSummary() {
819-
void showAndLogWarningMessage(`No evaluator log summary is available for this run. Perhaps it failed before evaluation, or you are running with a version of CodeQL before ${CliVersionConstraint.CLI_VERSION_WITH_PER_QUERY_EVAL_LOG}?`);
819+
void showAndLogWarningMessage(`Evaluator log summary and evaluator log are not available for this run. Perhaps they failed before evaluation, or you are running with a version of CodeQL before ${CliVersionConstraint.CLI_VERSION_WITH_PER_QUERY_EVAL_LOG}?`);
820820
}
821821

822+
private warnInProgressEvalLogSummary() {
823+
void showAndLogWarningMessage('The evaluator log summary is still being generated. Please try again later. The summary generation process is tracked in the "CodeQL Extension Log" view.');
824+
}
822825

823826
async handleShowEvalLog(
824827
singleItem: QueryHistoryInfo,
@@ -851,8 +854,15 @@ export class QueryHistoryManager extends DisposableObject {
851854

852855
if (finalSingleItem.evalLogSummaryLocation) {
853856
await this.tryOpenExternalFile(finalSingleItem.evalLogSummaryLocation);
854-
} else {
855-
this.warnNoEvalLogSummary();
857+
}
858+
// Summary log file doesn't exist.
859+
else {
860+
if (finalSingleItem.evalLogLocation && fs.pathExists(finalSingleItem.evalLogLocation)) {
861+
// If raw log does exist, then the summary log is still being generated.
862+
this.warnInProgressEvalLogSummary();
863+
} else {
864+
this.warnNoEvalLogSummary();
865+
}
856866
}
857867
}
858868

extensions/ql-vscode/src/run-queries.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,21 @@ export class QueryEvaluationInfo {
199199
});
200200
if (await this.hasEvalLog()) {
201201
queryInfo.evalLogLocation = this.evalLogPath;
202-
await qs.cliServer.generateLogSummary(this.evalLogPath, this.evalLogSummaryPath, this.evalLogEndSummaryPath);
203-
queryInfo.evalLogSummaryLocation = this.evalLogSummaryPath;
204-
fs.readFile(this.evalLogEndSummaryPath, (err, buffer) => {
205-
if (err) {
206-
throw new Error(`Could not read structured evaluator log end of summary file at ${this.evalLogEndSummaryPath}.`);
207-
}
208-
void qs.logger.log(' --- Evaluator Log Summary --- ');
209-
void qs.logger.log(buffer.toString());
210-
});
202+
void qs.cliServer.generateLogSummary(this.evalLogPath, this.evalLogSummaryPath, this.evalLogEndSummaryPath)
203+
.then(() => {
204+
queryInfo.evalLogSummaryLocation = this.evalLogSummaryPath;
205+
fs.readFile(this.evalLogEndSummaryPath, (err, buffer) => {
206+
if (err) {
207+
throw new Error(`Could not read structured evaluator log end of summary file at ${this.evalLogEndSummaryPath}.`);
208+
}
209+
void qs.logger.log(' --- Evaluator Log Summary --- ');
210+
void qs.logger.log(buffer.toString());
211+
});
212+
})
213+
214+
.catch(err => {
215+
void showAndLogWarningMessage(`Failed to generate structured evaluator log summary. Reason: ${err.message}`);
216+
});
211217
} else {
212218
void showAndLogWarningMessage(`Failed to write structured evaluator log to ${this.evalLogPath}.`);
213219
}

0 commit comments

Comments
 (0)