Repository navigation
tasks: pass task type through ITaskHandleDTO to prevent provider fanout - #336159
Megan Rogge (meganrogge) merged 2 commits into
Conversation
When executing a task obtained from fetchTasks(), the task is serialized
to the main thread as an ITaskHandleDTO. Previously, ITaskHandleDTO omitted
the task's type, causing $getTaskExecution() and $executeTask() in
mainThreadTask.ts to call taskService.getTask() without a type parameter.
When the task is not in tasks.json, AbstractTaskService falls back to
querying resolvers via _getGroupedTasks({ type: undefined }), which
activates all registered task providers across all extensions.
This updates ITaskHandleDTO to carry the optional type parameter from
the task definition and forwards it to taskService.getTask(), matching
the behavior of the internal task execution path.
Fixes microsoft#336152
There was a problem hiding this comment.
🟢 Approval recommended
The focused changes correctly preserve and consume the task type, with appropriate unit coverage.
Pull request overview
Threads task types through task handles to prevent unnecessary activation of unrelated task providers.
Changes:
- Adds task type to
ITaskHandleDTOand its serialization. - Uses the type when resolving task executions.
- Adds focused serialization coverage.
File summaries
| File | Description |
|---|---|
taskService.ts |
Exposes the existing optional type parameter. |
extHostTask.test.ts |
Tests task-type preservation. |
shared/tasks.ts |
Extends the task handle DTO. |
extHostTask.ts |
Serializes the task definition type. |
mainThreadTask.ts |
Passes the type into task lookup. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Hi Megan Rogge (@meganrogge), what are the chances of this PR being merged soon? This change has a significant impact on users of our VS Code extension: it would make VS Code feel much more responsive in our use cases and cut down on unwanted, unpredictable side effects during task execution. I'm happy to help or provide more context if that's useful. Thanks in advance! |
Megan Rogge (meganrogge)
left a comment
There was a problem hiding this comment.
Thanks, this looks good. getTask already supports filtering by type, so passing it through for executeTask() avoids activating every task provider.
| const workspace = this.getWorkspace(value.workspaceFolder); | ||
| if (workspace) { | ||
| const task = await this._taskService.getTask(workspace, value.id, true); | ||
| const task = await this._taskService.getTask(workspace, value.id, true, value.type); |
| const workspace = this.getWorkspace(value.workspaceFolder); | ||
| if (workspace) { | ||
| const task = await this._taskService.getTask(workspace, value.id, true); | ||
| const task = await this._taskService.getTask(workspace, value.id, true, value.type); |


Description
Fixes #336152
When calling
vscode.tasks.executeTask(task)with aTaskobtained fromvscode.tasks.fetchTasks({ type }),ExtHostTask.executeTask()serializes the task to the main thread as anITaskHandleDTO.Previously,
ITaskHandleDTOonly carried{ id, workspaceFolder }, dropping the task'stype.On the main thread, both
$getTaskExecution()and$executeTask()insrc/vs/workbench/api/browser/mainThreadTask.tscalled:Because provider-contributed tasks are not in
tasks.json,AbstractTaskService.getTask()falls back to:which activates all registered task providers across all installed extensions, causing unnecessary extension activation and delay.
Solution
type?: string;toITaskHandleDTOinsrc/vs/workbench/api/common/shared/tasks.ts.type: value.definition?.typeinTaskHandleDTO.from()insrc/vs/workbench/api/common/extHostTask.ts.ITaskService.getTaskmethod signature insrc/vs/workbench/contrib/tasks/common/taskService.tsto accepttype?: string.value.typeas the 4th argument in bothgetTask()calls inmainThreadTask.ts($getTaskExecutionand$executeTask), mirroring how PR Fix accidently starting all onTaskType extensions when running any task; fixes #175821 #178679 fixed this for internal executions.Verification
extHostTask.test.tsverifying thatTaskHandleDTO.from(task)preserves the task definition's type.npm run typecheck-client(0 errors).npm run hygiene(checked 12,042 files, 0 errors).