Skip to content

HTTP client connection leak in embedders causes file descriptor exhaustion #919

@choutos

Description

@choutos

Summary

The AsyncOpenAI, Ollama, and VoyageAI embedders create HTTP clients that are never explicitly closed. Over time, connections accumulate in CLOSE_WAIT state and eventually exhaust available file descriptors.

Symptoms

  • Too many open files errors after prolonged operation
  • Connections stuck in CLOSE_WAIT state (visible via ss -tan or netstat)
  • Gradual file descriptor exhaustion under sustained embedding workloads

Root Cause

The embedder classes instantiate HTTP clients (e.g., httpx.AsyncClient via the OpenAI SDK, or direct httpx usage in Ollama/VoyageAI) but lack cleanup logic to close them when the embedding loop exits.

Proposed Fix

See PR #917, which:

  • Adds a cleanup() method to the Embedder base class
  • Implements cleanup() in affected embedders to close underlying HTTP clients
  • Calls cleanup() in Executor.run()'s finally block
  • Reuses client instances instead of creating new ones per request (Ollama, VoyageAI)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions