Skip to content

Commit e23d4a9

Browse files
Make restarting the query server not cancellable, because in practice it wasn't
1 parent 47a5993 commit e23d4a9

File tree

3 files changed

+16
-27
lines changed

3 files changed

+16
-27
lines changed

extensions/ql-vscode/src/extension.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@ function getCommands(
183183

184184
const restartQueryServer = async () =>
185185
withProgress(
186-
async (progress: ProgressCallback, token: CancellationToken) => {
186+
async (progress: ProgressCallback) => {
187187
// Restart all of the spawned servers: cli, query, and language.
188188
cliServer.restartCliServer();
189189
await Promise.all([
190-
queryRunner.restartQueryServer(progress, token),
190+
queryRunner.restartQueryServer(progress),
191191
async () => {
192192
if (languageClient.isRunning()) {
193193
await languageClient.restart();
@@ -203,7 +203,6 @@ function getCommands(
203203
},
204204
{
205205
title: "Restarting Query Server",
206-
cancellable: true,
207206
},
208207
);
209208

extensions/ql-vscode/src/query-server/query-runner.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,11 @@ export class QueryRunner {
9191
return this.qs.logger;
9292
}
9393

94-
async restartQueryServer(
95-
progress: ProgressCallback,
96-
token: CancellationToken,
97-
): Promise<void> {
98-
await this.qs.restartQueryServer(progress, token);
94+
async restartQueryServer(progress: ProgressCallback): Promise<void> {
95+
await this.qs.restartQueryServer(progress);
9996
}
10097

101-
onStart(
102-
callBack: (
103-
progress: ProgressCallback,
104-
token: CancellationToken,
105-
) => Promise<void>,
106-
) {
98+
onStart(callBack: (progress: ProgressCallback) => Promise<void>) {
10799
this.qs.onDidStartQueryServer(callBack);
108100
}
109101

extensions/ql-vscode/src/query-server/query-server-client.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { ProgressReporter } from "../common/logging/vscode";
1414
import { extLogger } from "../common/logging/vscode";
1515
import type { ProgressMessage, WithProgressId } from "./messages";
1616
import { progress } from "./messages";
17-
import type { ProgressCallback, ProgressTask } from "../common/vscode/progress";
17+
import type { ProgressCallback } from "../common/vscode/progress";
1818
import { withProgress } from "../common/vscode/progress";
1919
import { ServerProcess } from "./server-process";
2020
import type { App } from "../common/app";
@@ -51,12 +51,16 @@ export class QueryServerClient extends DisposableObject {
5151

5252
withProgressReporting: WithProgressReporting;
5353

54-
private readonly queryServerStartListeners = [] as Array<ProgressTask<void>>;
54+
private readonly queryServerStartListeners = [] as Array<
55+
(progress: ProgressCallback) => void
56+
>;
5557

5658
// Can't use standard vscode EventEmitter here since they do not cause the calling
5759
// function to fail if one of the event handlers fail. This is something that
5860
// we need here.
59-
readonly onDidStartQueryServer = (e: ProgressTask<void>) => {
61+
readonly onDidStartQueryServer = (
62+
e: (progress: ProgressCallback) => void,
63+
) => {
6064
this.queryServerStartListeners.push(e);
6165
};
6266

@@ -105,14 +109,11 @@ export class QueryServerClient extends DisposableObject {
105109
* This resets the unexpected termination count. As hopefully it is an indication that the user has fixed the
106110
* issue.
107111
*/
108-
async restartQueryServer(
109-
progress: ProgressCallback,
110-
token: CancellationToken,
111-
): Promise<void> {
112+
async restartQueryServer(progress: ProgressCallback): Promise<void> {
112113
// Reset the unexpected termination count when we restart the query server manually
113114
// or due to config change
114115
this.unexpectedTerminationCount = 0;
115-
await this.restartQueryServerInternal(progress, token);
116+
await this.restartQueryServerInternal(progress);
116117
}
117118

118119
/**
@@ -121,11 +122,9 @@ export class QueryServerClient extends DisposableObject {
121122
private restartQueryServerOnFailure() {
122123
if (this.unexpectedTerminationCount < MAX_UNEXPECTED_TERMINATIONS) {
123124
void withProgress(
124-
async (progress, token) =>
125-
this.restartQueryServerInternal(progress, token),
125+
async (progress) => this.restartQueryServerInternal(progress),
126126
{
127127
title: "Restarting CodeQL query server due to unexpected termination",
128-
cancellable: true,
129128
},
130129
);
131130
} else {
@@ -145,15 +144,14 @@ export class QueryServerClient extends DisposableObject {
145144
*/
146145
private async restartQueryServerInternal(
147146
progress: ProgressCallback,
148-
token: CancellationToken,
149147
): Promise<void> {
150148
this.stopQueryServer();
151149
await this.startQueryServer();
152150

153151
// Ensure we await all responses from event handlers so that
154152
// errors can be properly reported to the user.
155153
await Promise.all(
156-
this.queryServerStartListeners.map((handler) => handler(progress, token)),
154+
this.queryServerStartListeners.map((handler) => handler(progress)),
157155
);
158156
}
159157

0 commit comments

Comments
 (0)