Skip to content

Fix leak errors from disposed ChatThinkingContentPart during thinking stream#277264

Merged
vijayupadya merged 11 commits intomicrosoft:mainfrom
vijayupadya:vijayu/ChatListItemRenderer_leak2
Nov 13, 2025
Merged

Fix leak errors from disposed ChatThinkingContentPart during thinking stream#277264
vijayupadya merged 11 commits intomicrosoft:mainfrom
vijayupadya:vijayu/ChatListItemRenderer_leak2

Conversation

@vijayupadya
Copy link
Contributor

Fixes #277260

Fixes leak errors when late thinking updates tried to register disposables on an already disposed ChatThinkingContentPart.

Root Cause

Asynchronous streaming updates (title/thinking text) continued arriving for a stale ChatThinkingContentPart after it was disposed (list diff, deletion, regenerate).

Few scenarios to repro:

  • Stop and rapid regenerate
  • Collapse/Expand churn during streaming
  • View switch during streaming

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes memory leak errors that occurred when asynchronous streaming updates arrived for a ChatThinkingContentPart after it had already been disposed. The root cause was that during rapid operations like regeneration, view switching, or collapse/expand, the part could be disposed while async updates were still in flight.

Key Changes

  • Added disposal guards using this._store.isDisposed checks in three critical methods
  • Prevents registration of new disposables on disposed objects
  • Follows established disposal pattern used throughout the codebase

@vijayupadya vijayupadya merged commit f9d7b8e into microsoft:main Nov 13, 2025
22 of 23 checks passed
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChatThinkingContentPart leak errors

3 participants