Change:
a debug config like and a task like F5. You're all good the window. Hit F5 again, and observe the terminal with the task gets restored. get this dialog. I don't really want either of these options, it's already a background task that should be in the 'end' state  or restart the task and try to F5 again. This doesn't work either and you have to reload the window to get debugging work again
Did this work until recently?
Also doesn't a pre launch task get run every time one debugs?
I think so... I honestly don't use preLaunchTask's as much as I should due to a history of papercuts, but I definitely haven't seen this notification before. Yea, but if it's a background task that's already running it shouldn't get run again. I'm not sure how much of this issue is in debug vs tasks
The task stops running on reload of the window because the terminal is killed. That's why it has to run again on window reload. Perhaps the solution is to not reconnect (IE restart) prelaunch tasks.
Currently, we persist any background task that has problem matchers.
Should have been fixed with , pls reopen if not
I can still repro in today's Insiders
are you reproducing using the task above?
I'm using a simpler task following the other issue:
works when I use . So has to do with debugging specifically

Discussion:
import { ITaskService, ITaskSummary } from 'vs/workbench/contrib/tasks/common/taskService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IWorkspaceFolder, IWorkspace } from 'vs/platform/workspace/common/workspace'; <del> import { ITaskEvent, TaskEventKind, ITaskIdentifier } from 'vs/workbench/contrib/tasks/common/tasks'; </del> <ins> import { ITaskEvent, TaskEventKind, ITaskIdentifier, Task } from 'vs/workbench/contrib/tasks/common/tasks'; </ins> import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { IMarkerService, MarkerSeverity } from 'vs/platform/markers/common/markers'; import { IDebugConfiguration } from 'vs/workbench/contrib/debug/common/debug';

// If a task is missing the problem matcher the promise will never complete, so we need to have a workaround #35340 let taskStarted = false; <del> const taskKey = task.getMapKey(); </del> <ins> const getTaskKey = (t: Task) => t.getKey() ?? t.getMapKey(); const taskKey = getTaskKey(task); </ins> const inactivePromise: Promise<ITaskSummary | null> = new Promise((c) => once(e => { // When a task isBackground it will go inactive when it is safe to launch. // But when a background task is terminated by the user, it will also fire an inactive event.

// Catch the ProcessEnded event here, which occurs before inactive, and capture the exit code to prevent this. return (e.kind === TaskEventKind.Inactive || (e.kind === TaskEventKind.ProcessEnded && e.exitCode === undefined)) <del> && e.__task?.getMapKey() === taskKey; </del> <ins> && getTaskKey(e.__task) === taskKey; </ins> }, this.taskService.onDidStateChange)(e => { taskStarted = true; c(e.kind === TaskEventKind.ProcessEnded ? { exitCode: e.exitCode } : null); })); const promise: Promise<ITaskSummary | null> = this.taskService.getActiveTasks().then(async (tasks): Promise<ITaskSummary | null> => { <del> if (tasks.find(t => t.getMapKey() === taskKey)) { </del> <ins> if (tasks.find(t => getTaskKey(t) === taskKey)) { </ins> // Check that the task isn't busy and if it is, wait for it const busyTasks = await this.taskService.getBusyTasks(); <del> if (busyTasks.find(t => t.getMapKey() === taskKey)) { </del> <ins> if (busyTasks.find(t => getTaskKey(t) === taskKey)) { </ins> taskStarted = true; return inactivePromise; } // task is already running and isn't busy - nothing to do. return Promise.resolve(null); } <del> once(e => ((e.kind === TaskEventKind.Active) || (e.kind === TaskEventKind.DependsOnStarted)) && e.__task?.getMapKey() === taskKey, this.taskService.onDidStateChange)(() => { </del> <ins> once(e => ((e.kind === TaskEventKind.Active) || (e.kind === TaskEventKind.DependsOnStarted)) && getTaskKey(e.__task) === taskKey, this.taskService.onDidStateChange)(() => { </ins> // Task is active, so everything seems to be fine, no need to prompt after 10 seconds // Use case being a slow running task should not be prompted even though it takes more than 10 seconds taskStarted = true;

}); return new Promise((c, e) => { <del> const waitForInput = new Promise<void>(resolve => once(e => (e.kind === TaskEventKind.AcquiredInput) && e.__task?.getMapKey() === taskKey, this.taskService.onDidStateChange)(() => { </del> <ins> const waitForInput = new Promise<void>(resolve => once(e => (e.kind === TaskEventKind.AcquiredInput) && getTaskKey(e.__task) === taskKey, this.taskService.onDidStateChange)(() => { </ins> resolve(); }));