Explicitly set task execution way before running task

Part of #100361
This commit is contained in:
Alex Ross
2020-06-17 13:38:29 +02:00
parent 1d2432f094
commit 1abf21d3d8
4 changed files with 47 additions and 37 deletions

View File

@@ -53,7 +53,13 @@ export class ExtHostTask extends ExtHostTaskBase {
const tTask = (task as types.Task);
// We have a preserved ID. So the task didn't change.
if (tTask._id !== undefined) {
return this._proxy.$executeTask(TaskHandleDTO.from(tTask)).then(value => this.getTaskExecution(value, task));
// Always get the task execution first to prevent timing issues when retrieving it later
const executionDTO = await this._proxy.$getTaskExecution(TaskHandleDTO.from(tTask));
if (executionDTO.task === undefined) {
throw new Error('Task from execution DTO is undefined');
}
const execution = await this.getTaskExecution(executionDTO, task);
return this._proxy.$executeTask(executionDTO.task).then(() => execution);
} else {
const dto = TaskDTO.from(task, extension);
if (dto === undefined) {
@@ -66,8 +72,9 @@ export class ExtHostTask extends ExtHostTaskBase {
if (CustomExecutionDTO.is(dto.execution)) {
await this.addCustomExecution(dto, task, false);
}
return this._proxy.$executeTask(dto).then(value => this.getTaskExecution(value, task));
// 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);
}
}