fix(feishu): finalize remote document downloads inside httpx.AsyncClient context#18502
Closed
beibi9966 wants to merge 1 commit into
Closed
fix(feishu): finalize remote document downloads inside httpx.AsyncClient context#18502beibi9966 wants to merge 1 commit into
beibi9966 wants to merge 1 commit into
Conversation
…context Ensure response bytes and Content-Type are captured before AsyncClient teardown to avoid lingering TCP halves under gateway-wide connection pressure (NousResearch#18451). Adds a regression test that orders content reads before client exit.
teknium1
pushed a commit
that referenced
this pull request
May 2, 2026
…ent context (#18502) Snapshot Content-Type and body while the client context is still active so pooled connections fully release on exit. Previously the read happened after `async with httpx.AsyncClient(...)` returned — which works today only because httpx eagerly buffers non-streaming responses; a future refactor to `.stream()` would silently read- after-close. Part of the #18451 connection-hygiene audit. Salvage of #18502.
teknium1
added a commit
that referenced
this pull request
May 2, 2026
Follow-up for PR #18502 salvage.
Contributor
|
Merged via #18766 — your Feishu hygiene fix landed on current main with authorship preserved (rebase-merge). Widened the scope beyond your PR after auditing every persistent httpx/aiohttp client in the gateway tree: also closed a WhatsApp aiohttp leak (bare Thanks for the initial catch — it triggered the broader audit. |
nickdlkk
pushed a commit
to nickdlkk/hermes-agent
that referenced
this pull request
May 11, 2026
…ent context (NousResearch#18502) Snapshot Content-Type and body while the client context is still active so pooled connections fully release on exit. Previously the read happened after `async with httpx.AsyncClient(...)` returned — which works today only because httpx eagerly buffers non-streaming responses; a future refactor to `.stream()` would silently read- after-close. Part of the NousResearch#18451 connection-hygiene audit. Salvage of NousResearch#18502.
nickdlkk
pushed a commit
to nickdlkk/hermes-agent
that referenced
this pull request
May 11, 2026
Follow-up for PR NousResearch#18502 salvage.
jsboige
pushed a commit
to jsboige/hermes-agent
that referenced
this pull request
May 14, 2026
…ent context (NousResearch#18502) Snapshot Content-Type and body while the client context is still active so pooled connections fully release on exit. Previously the read happened after `async with httpx.AsyncClient(...)` returned — which works today only because httpx eagerly buffers non-streaming responses; a future refactor to `.stream()` would silently read- after-close. Part of the NousResearch#18451 connection-hygiene audit. Salvage of NousResearch#18502.
jsboige
pushed a commit
to jsboige/hermes-agent
that referenced
this pull request
May 14, 2026
Follow-up for PR NousResearch#18502 salvage.
dannyJ848
pushed a commit
to dannyJ848/hermes-agent
that referenced
this pull request
May 17, 2026
…ent context (NousResearch#18502) Snapshot Content-Type and body while the client context is still active so pooled connections fully release on exit. Previously the read happened after `async with httpx.AsyncClient(...)` returned — which works today only because httpx eagerly buffers non-streaming responses; a future refactor to `.stream()` would silently read- after-close. Part of the NousResearch#18451 connection-hygiene audit. Salvage of NousResearch#18502.
dannyJ848
pushed a commit
to dannyJ848/hermes-agent
that referenced
this pull request
May 17, 2026
Follow-up for PR NousResearch#18502 salvage.
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…ent context (NousResearch#18502) Snapshot Content-Type and body while the client context is still active so pooled connections fully release on exit. Previously the read happened after `async with httpx.AsyncClient(...)` returned — which works today only because httpx eagerly buffers non-streaming responses; a future refactor to `.stream()` would silently read- after-close. Part of the NousResearch#18451 connection-hygiene audit. Salvage of NousResearch#18502.
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
Follow-up for PR NousResearch#18502 salvage.
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
…ent context (NousResearch#18502) Snapshot Content-Type and body while the client context is still active so pooled connections fully release on exit. Previously the read happened after `async with httpx.AsyncClient(...)` returned — which works today only because httpx eagerly buffers non-streaming responses; a future refactor to `.stream()` would silently read- after-close. Part of the NousResearch#18451 connection-hygiene audit. Salvage of NousResearch#18502.
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
Follow-up for PR NousResearch#18502 salvage.
Seven74AI
pushed a commit
to Seven74AI/hermes-agent
that referenced
this pull request
Jun 13, 2026
…ent context (NousResearch#18502) Snapshot Content-Type and body while the client context is still active so pooled connections fully release on exit. Previously the read happened after `async with httpx.AsyncClient(...)` returned — which works today only because httpx eagerly buffers non-streaming responses; a future refactor to `.stream()` would silently read- after-close. Part of the NousResearch#18451 connection-hygiene audit. Salvage of NousResearch#18502.
Seven74AI
pushed a commit
to Seven74AI/hermes-agent
that referenced
this pull request
Jun 13, 2026
Follow-up for PR NousResearch#18502 salvage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Feishu outbound document fetch (
_download_remote_document) previously readresponse.headers/response.contentafter exitingasync with httpx.AsyncClient(...). That can leave pooled HTTP connections in an awkward shutdown window and adds avoidable pressure on process file descriptors in long-running gateways (see #18451).This change snapshots
Content-Typeand the response body while the client context is still active, then passes bytes intocache_document_from_bytes.Test plan
pytest tests/gateway/test_feishu.py::TestAdapterBehavior::test_download_remote_document_reads_response_before_httpx_client_closes -qRelated