sdk/shreds: bound RPC client request timeout and connection pool#3974
Open
nikw9944 wants to merge 1 commit into
Open
sdk/shreds: bound RPC client request timeout and connection pool#3974nikw9944 wants to merge 1 commit into
nikw9944 wants to merge 1 commit into
Conversation
The shreds SDK RPC client wrapped http.DefaultClient, which has no request timeout and keeps only 2 idle connections per host. Against a slow or degraded ledger RPC endpoint a request can block indefinitely, long enough for a transaction's recent blockhash to expire before it is sent, surfacing as BlockhashNotFound. Configure the underlying http.Client with a bounded 15s per-request timeout and a connection pool sized for concurrent use so requests fail fast and the caller can retry with a fresh blockhash.
martinsander00
approved these changes
Jul 3, 2026
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 of Changes
http.DefaultClient.This is the SDK-level counterpart to the internet-latency-collector hardening (#3973).
http.DefaultClienthas no request timeout and keeps only 2 idle connections per host, so against a slow or degraded ledger RPC endpoint a request can block indefinitely — long enough for a transaction's recent blockhash to expire before it is sent, which surfaces asBlockhashNotFoundat preflight. A bounded timeout makes requests fail fast so the caller can retry with a fresh blockhash. The existing transient-error retry wrapper is unchanged.Diff Breakdown
Small change: RPC-client construction hardening plus a test; no logic/algorithm changes.
Key files (click to expand)
sdk/shreds/go/rpc.go— addnewHTTPClient(bounded timeout + sized transport) and use it for the RPC client's inner HTTP client instead ofhttp.DefaultClient.sdk/shreds/go/rpc_test.go— new tests asserting the client has a bounded timeout and that a slow request is aborted near the timeout rather than hanging.Testing Verification
TestNewHTTPClient_HasBoundedTimeout: the constructed client has a non-zero timeout and a connection pool sized todefaultMaxConns(guards against regressing back tohttp.DefaultClient).TestNewHTTPClient_TimesOutSlowRequest: a request to a handler that sleeps 3s is aborted within ~200ms, confirming requests are bounded.Note
The identical unbounded-
http.DefaultClientpattern exists insdk/revdist/go/rpc.go; left out of this PR to keep it focused, but worth a follow-up.