-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
name: Bug Report
description: Potentially Undisposed SDK Clients in API Providers
labels: ["bug", "memory-leak", "likely", "api-providers", "auto-generated"]
Thanks for your report! Please check existing issues first:
👉 https://github.com/RooCodeInc/Roo-Code/issues
App Version
N/A (Static Analysis - Detected in api_provider_clients)
API Provider
Multiple (Anthropic, OpenAI, Gemini, Ollama, Bedrock, OpenRouter)
Model Used
N/A (SDK Clients)
🔁 Steps to Reproduce
- Setup: A
Taskinstance is created, which in turn instantiates an API provider handler (e.g.,AnthropicHandler,OpenAIHandler). - Exact actions:
- The API provider handler's constructor creates an SDK client (e.g.,
new Anthropic(),new OpenAI()). - The
Taskinstance is later aborted or disposed of, or an error occurs preventing its full cleanup.
- The API provider handler's constructor creates an SDK client (e.g.,
- What happened after each step:
- The
Task.abortTask()orTask.dispose()methods are called (or are intended to be called). - Currently, these methods do not explicitly call a
disposemethod on thethis.apihandler. - The API provider handlers themselves do not have
disposemethods to clean up their SDK clients. - The SDK client may remain active, potentially holding resources like network connections or internal caches.
- The
💥 Outcome Summary
Expected all SDK clients created by API provider handlers to be explicitly disposed of when the parent Task is cleaned up. However, the lack of dispose methods in the handlers and the Task not calling such methods on its api property can lead to resource leaks if SDKs do not perfectly self-manage all resources or if Task instances are orphaned.
📄 Relevant Logs or Errors (Optional)
Summary from leak-report/likely/api_provider_clients.md:
Various API provider handlers ... instantiate SDK client objects in their constructors... These provider handler classes do not have explicit
dispose()orclose()methods... If aTaskinstance is not properly disposed of... theApiHandlerinstance it holds, along with the underlying SDK client, will also not be explicitly cleaned up. TheTask.abortTask()method does not currently have explicit calls to dispose of itsthis.apihandler.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status