From d52f137ed539400ccb4c8518a43e9a3fd70ff818 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Wed, 17 Jun 2020 13:54:21 +0200 Subject: [PATCH] Return task execution early from executeTask Fixes #100361 --- src/vs/workbench/api/common/extHostTask.ts | 5 +++-- src/vs/workbench/api/node/extHostTask.ts | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/api/common/extHostTask.ts b/src/vs/workbench/api/common/extHostTask.ts index fd67691d82b..32f042f6cd7 100644 --- a/src/vs/workbench/api/common/extHostTask.ts +++ b/src/vs/workbench/api/common/extHostTask.ts @@ -706,7 +706,7 @@ export class WorkerExtHostTask extends ExtHostTaskBase { public async executeTask(extension: IExtensionDescription, task: vscode.Task): Promise { const dto = TaskDTO.from(task, extension); if (dto === undefined) { - return Promise.reject(new Error('Task is not valid')); + throw new Error('Task is not valid'); } // If this task is a custom execution, then we need to save it away @@ -720,7 +720,8 @@ export class WorkerExtHostTask extends ExtHostTaskBase { // Always get the task execution first to prevent timing issues when retrieving it later const execution = await this.getTaskExecution(await this._proxy.$getTaskExecution(dto), task); - return this._proxy.$executeTask(dto).then(() => execution); + this._proxy.$executeTask(dto).catch(error => { throw new Error(error); }); + return execution; } protected provideTasksInternal(validTypes: { [key: string]: boolean; }, taskIdPromises: Promise[], handler: HandlerData, value: vscode.Task[] | null | undefined): { tasks: tasks.TaskDTO[], extension: IExtensionDescription } { diff --git a/src/vs/workbench/api/node/extHostTask.ts b/src/vs/workbench/api/node/extHostTask.ts index 8f21cd8c316..b785156b037 100644 --- a/src/vs/workbench/api/node/extHostTask.ts +++ b/src/vs/workbench/api/node/extHostTask.ts @@ -59,7 +59,8 @@ export class ExtHostTask extends ExtHostTaskBase { throw new Error('Task from execution DTO is undefined'); } const execution = await this.getTaskExecution(executionDTO, task); - return this._proxy.$executeTask(executionDTO.task).then(() => execution); + this._proxy.$executeTask(executionDTO.task).catch(error => { throw new Error(error); }); + return execution; } else { const dto = TaskDTO.from(task, extension); if (dto === undefined) { @@ -74,7 +75,8 @@ export class ExtHostTask extends ExtHostTaskBase { } // Always get the task execution first to prevent timing issues when retrieving it later const execution = await this.getTaskExecution(await this._proxy.$getTaskExecution(dto), task); - return this._proxy.$executeTask(dto).then(() => execution); + this._proxy.$executeTask(dto).catch(error => { throw new Error(error); }); + return execution; } } -- GitLab