kubeflow / kubeflow/docs-agent

bug: httpx.AsyncClient created per-request in server-https/app.py

Open Beginner friendly
#75 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
42
Forks
111
Avg merge
6d 23m
Merged PRs (30d)
2

Description

Context

server-https/app.py (line 202) creates a new httpx.AsyncClient on every incoming request rather than reusing a shared instance.

Problem

Every request opens a new connection pool and tears it down — redundant TLS handshakes, file descriptor churn, no benefit from HTTP keep-alive. Under any real load this becomes measurable overhead and can exhaust fd limits.

Why This Order

Same file as the CORS fix (#76) and replacing the linear query flow in server-https/app.py. Fix the client lifecycle first so subsequent changes don't build on top of the broken pattern.

Acceptance Criteria

  • A single httpx.AsyncClient is created at app startup via FastAPI lifespan
  • All route handlers reuse it via request.app.state
  • Client is properly closed on shutdown — no ResourceWarning in tests

Related

  • server-https/app.py:202
  • Parent tracking issue: #72
  • Blocks: Kagent agent layer and replacing the linear query flow in server-https/app.py

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in server-https/app.py at line 202 and trace how the FastAPI application and route handlers access the HTTP client. Move client creation into the app lifespan and make handlers reuse the shared instance through request.app.state. Done means one client is created at startup, closed on shutdown, and tests produce no ResourceWarning.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.