Skip to content

fix: memory leak in task providers - #338231

Merged
Dmitriy Vasyura (dmitrivMS) merged 8 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-taskProvider-rejections
Nov 9, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 8 commits into
microsoft:mainfrom
SimonSiefke:fix/memory-leak-taskProvider-rejections

Conversation

@SimonSiefke

Copy link
Copy Markdown
Contributor

Details

When a task provider fails, its extension-host request never resolves or rejects. The workbench stops waiting after five seconds, but the RPC reply and task-discovery callbacks are not removed. Failed custom task-ID creation has the same problem.

Change

Propagate provider and task-ID failures to the caller while still waiting for custom task IDs before returning successful results.

Before

Fetching tasks from a failing provider 37 times leaves 37 pending RPC replies, 37 lazy promises, and their task-discovery callbacks:

before

After

No more pending RPC reply or task-discovery callback growth is detected in the same 37-cycle test.

Test Video

The sample provider deliberately fails; each completed refresh dismisses the expected task-error notification.

test.mp4

AI disclosure: Model: GPT 6 Astra. Worktime: 35 min

Copilot AI balanced review requested due to automatic review settings September 27, 2026 18:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused implementation correctly resolves the leak and is covered by relevant regression tests.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes task-provider failure propagation so RPC requests and discovery callbacks can settle instead of leaking.

Changes:

  • Propagates provider and custom task-ID failures.
  • Preserves waiting for successful custom task-ID creation.
  • Adds regression tests for failures, waiting, and empty results.
File Description
src/​vs/​workbench/​api/​common/​extHostTask.ts Uses async error propagation while awaiting custom task IDs.
src/​vs/​workbench/​api/​test/​browser/​extHostTask.test.ts Covers synchronous/asynchronous failures and successful completion.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@dmitrivMS Dmitriy Vasyura (dmitrivMS) added the freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues label Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

@meganrogge

Copy link
Copy Markdown
Collaborator

Copilot resolve the merge conflicts in this pull request

@meganrogge
Megan Rogge (meganrogge) marked this pull request as ready for review October 30, 2026 16:57
@meganrogge
Megan Rogge (meganrogge) marked this pull request as draft October 30, 2026 16:57
@meganrogge

Copy link
Copy Markdown
Collaborator

Copilot resolve the merge conflicts in this pull request

@SimonSiefke

Copy link
Copy Markdown
Contributor Author

Fixed merged conflicts.

The other PR #339387 is also still open, but seems more like an edge case fix and doesn't necessarily need to come before this PR.

@meganrogge

Copy link
Copy Markdown
Collaborator

Thanks for resolving the conflicts! Per Dmitriy's review, #339387 needs to land first, since without it a late provider failure can drop a healthy provider's tasks. Dmitriy Vasyura (@dmitrivMS), could you take the review on #339387? Then we can merge this one after it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test asserts before the result callback can run, so it still passes if task-ID waiting is removed and does not protect the required custom-ID ordering.

1 open issue

Review effort: Max

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@dmitrivMS

Copy link
Copy Markdown
Collaborator

Simon Siefke (@SimonSiefke) Thank you!

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit e0adcb5 into microsoft:main Nov 9, 2026
59 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 9, 2026
@SimonSiefke
Simon Siefke (SimonSiefke) deleted the fix/memory-leak-taskProvider-rejections branch November 11, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues tasks Task system issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants