Repository navigation
fix(protocol): keep direct RPC connections alive while awaiting a reply - #883
Open
morningducke wants to merge 5 commits into
Open
morningducke wants to merge 5 commits into
morningducke wants to merge 5 commits into
Conversation
morningducke
marked this pull request as ready for review
November 24, 2026 13:39
This branch has not been deployed
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.
What and why
Long-running data-plane RPCs can lose an idle direct TCP connection while the environment prepares its reply. Enable keepalive on the direct connections used by
data/add,data/getanddata/reset. Where the kernel supports them, probing starts after 30 seconds of inactivity with a 10-second interval and three probes.Apply each setting to the connected socket. A kernel can expose a setting to Python and still reject it on that socket. The remaining settings and the RPC continue in that case. HTTPX handles proxy routing, bypasses and TLS verification.
Verification
e4e8151. All sixteen passed with this change on HTTPX 0.27.0 and 0.28.1. A loopback peer received one request when the socket rejectedTCP_KEEPINTVL, and observed the connection close.data/addclients against one temporary E2B server. Both short controls succeeded. For the paired long calls the server waited 315 seconds before sending headers and completed both writes. The stock client raisedReadTimeoutafter 361.461 seconds. The patched client received its result after 315.686 seconds.nginx:alpinefrom the Docker mirror with HTTP 429. GitHub requires an upstream repository administrator to rerun that job. Failed gateway job

Confidence Score: 5/5
The PR appears safe to merge; no blocking issue was found.Summary
The PR adds best-effort TCP keepalive to direct data-plane RPC connections.
The previous unnumbered finding is fixed: the three keepalive values now have descriptive class constants.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD RPC["data/add, data/get, data/reset"] --> Client["rpc_client"] Client --> Route{"HTTPX route"} Route -->|Direct or proxy bypass| Direct["_DirectTransport"] Route -->|Proxy| Proxy["AsyncHTTPTransport"] Direct --> Socket["Connected TCP socket"] Socket --> Settings["Try each keepalive setting"] Settings --> Reply["Await reply"] Proxy --> ReplyReviews (3) · Last reviewed commit: "Merge branch 'main' into fix/protocol-rp..." · Reviewed by Greptile