diff --git a/extension/src/server.ts b/extension/src/server.ts index f0ad0e8b8..62fc0c1ef 100644 --- a/extension/src/server.ts +++ b/extension/src/server.ts @@ -15,8 +15,7 @@ export interface ServerOptions { } export class GradleTasksServer implements vscode.Disposable { - private task?: vscode.Task; - private taskExecution?: Thenable; + private taskExecution?: vscode.TaskExecution; private _onReady: vscode.EventEmitter = new vscode.EventEmitter(); private _onStop: vscode.EventEmitter = new vscode.EventEmitter(); private isRestarting = false; @@ -42,7 +41,6 @@ export class GradleTasksServer implements vscode.Disposable { logger.info( localize('server.gradleServerStopped', 'Gradle server stopped') ); - this.task = undefined; this.taskExecution = undefined; this.showRestartMessage(); } @@ -58,16 +56,16 @@ export class GradleTasksServer implements vscode.Disposable { } else { this.port = await getPort(); const cwd = this.context.asAbsolutePath('lib'); - this.task = buildGradleServerTask(SERVER_TASK_NAME, cwd, [ + const task = buildGradleServerTask(SERVER_TASK_NAME, cwd, [ String(this.port), ]); logger.debug('Starting server'); - this.taskExecution = vscode.tasks.executeTask(this.task); + this.taskExecution = await vscode.tasks.executeTask(task); } } public isStarted(): boolean { - return this.task !== undefined; + return this.taskExecution !== undefined; } public async showRestartMessage(): Promise { @@ -89,7 +87,7 @@ export class GradleTasksServer implements vscode.Disposable { localize('server.gradleServerRestarting', 'Restarting gradle server') ); if (!this.isRestarting) { - if (this.task) { + if (this.taskExecution) { this.isRestarting = true; const disposable = vscode.tasks.onDidEndTaskProcess((event) => { if (event.execution.task.name === SERVER_TASK_NAME) { @@ -98,7 +96,7 @@ export class GradleTasksServer implements vscode.Disposable { this.start(); } }); - this.taskExecution?.then((execution) => execution.terminate()); + this.taskExecution?.terminate(); } else { this.start(); } @@ -113,7 +111,7 @@ export class GradleTasksServer implements vscode.Disposable { } public dispose(): void { - this.taskExecution?.then((execution) => execution.terminate()); + this.taskExecution?.terminate(); this._onReady.dispose(); this._onStop.dispose(); } diff --git a/extension/src/test/testUtil.ts b/extension/src/test/testUtil.ts index fb361f6f5..aee14181c 100644 --- a/extension/src/test/testUtil.ts +++ b/extension/src/test/testUtil.ts @@ -23,7 +23,7 @@ export function createTestRunner(pattern: string) { // Create the mocha test const mocha = new Mocha({ ui: 'bdd', - timeout: 90000, + timeout: 60000, color: true, }); mocha.bail(true);