Skip to content

Reuse gateway model proxy HTTP clients per service - #4491

Open
nikitabhagat2307-prog wants to merge 2 commits into
dstackai:masterfrom
nikitabhagat2307-prog:issue_4489_gateway_http_client_leak
Open

nikitabhagat2307-prog wants to merge 2 commits into
dstackai:masterfrom
nikitabhagat2307-prog:issue_4489_gateway_http_client_leak

Conversation

@nikitabhagat2307-prog

@nikitabhagat2307-prog nikitabhagat2307-prog commented Nov 14, 2026 •

Copy link
Copy Markdown

Fixes #4489.

The gateway model proxy created a new HTTPX client for every request to a domain-backed service and never closed it. Cache a ServiceClient per project/service in ServiceConnectionPool, reuse it across requests, close it when the service is unregistered, and close all remaining clients during pool shutdown.

Added focused lifecycle coverage for concurrent client reuse, client closure on service removal, and pool shutdown cleanup.

Validation: git diff --check passed. The documented Ruff checks and focused pytest module could not run because uv, ruff, and pytest are not installed in this environment. This contribution was prepared with AI assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Gateway model proxy creates an HTTP client per request and never closes it

1 participant