Change:
if (result) { return result; } <del> const createdResult: Promise<TaskExecutionImpl> = new Promise((resolve, reject) => { function resolvePromiseWithCreatedTask(that: ExtHostTaskBase, execution: tasks.ITaskExecutionDTO, taskToCreate: vscode.Task | types.Task | undefined) { if (!taskToCreate) { reject('Unexpected: Task does not exist.'); } else { resolve(new TaskExecutionImpl(that, execution.id, taskToCreate)); } } if (task) { resolvePromiseWithCreatedTask(this, execution, task); } else { TaskDTO.to(execution.task, this._workspaceProvider, this._providedCustomExecutions2) .then(task => resolvePromiseWithCreatedTask(this, execution, task)); } }); this._taskExecutionPromises.set(execution.id, createdResult); return createdResult.then(executionCreatedResult => { this._taskExecutions.set(execution.id, executionCreatedResult); return executionCreatedResult; }, rejected => { return Promise.reject(rejected); </del> <ins> let executionPromise: Promise<TaskExecutionImpl>; if (!task) { executionPromise = TaskDTO.to(execution.task, this._workspaceProvider, this._providedCustomExecutions2).then(t => { if (!t) { throw new ErrorNoTelemetry('Unexpected: Task does not exist.'); } return new TaskExecutionImpl(this, execution.id, t); }); } else { executionPromise = Promise.resolve(new TaskExecutionImpl(this, execution.id, task)); } this._taskExecutionPromises.set(execution.id, executionPromise); return executionPromise.then(taskExecution => { this._taskExecutions.set(execution.id, taskExecution); return taskExecution; </ins> }); }

Discussion:
Type: <bBug</bclone repro from and open project folder run the repro extension from vscode open two folders in the workspace (these will not be touched by the repro code, the problem was encounterd in multi-folder workspace and this just reproduces that environment) run command after some time popup with error will appear Expected beahvior: the loop running the dummy task will keep running indefinitely This seems to be caused by using in combination with changes of the workspace folders. When the loop in the repro is changed to only keep writing the file and running the tasks the problem never appears VS Code version: Code - Insiders 1.82.0-insider (, 2023-09-01T11:05:38.381Z) OS version: Linux x64 4.19.0-18-amd64 Modes: <details<summarySystem Info</summary </details<details<summaryExtensions (0)</summaryExtensionVersion ------ </details<details<summaryA/B Experiments</summary</details<!-- generated by issue reporter --
I'm not seeing the task you said to run in that folder !
The repro steps say to run command , not a task. The command runs the task itself via the API. Here is the command in the command pallette ! And here is the error it produces ! Please try the repro steps again and let me know if you still can't see what I show in the screenshots
I get this error, which is interesting because the workspace contains two folders. !
From the screenshot it seems like you have one workspace folder containing two file system folders - that still means the workspace is a single root workspace You need to have a multi-root workspace by calling I hope the terminology I use is correct, it is taken from this doc
PR fixing it