Repository navigation
fix(common): bound AlchemyRestClient requests with timeout + AbortSignal - #2571
Open
hermiondev wants to merge 1 commit into
Open
hermiondev wants to merge 1 commit into
hermiondev wants to merge 1 commit into
Conversation
The bare fetch() in AlchemyRestClient.request() passed no signal and the params type exposed no timeout/AbortSignal option, so a stalled upstream (TCP accepted, never replies) left the promise unsettled forever - 12s hang reproduced against the published @alchemy/common@5.2.7 dist with a never-replying local server. Add client-level timeout (default 10_000ms, matching the viem http transport used by the JSON-RPC sibling) and optional AbortSignal; every request is now bounded and rejects with the existing FetchError. Before: hangs past 15s watchdog kill. After: FetchError at 3002ms on timeout:3000 probe.
hermiondev
requested review from
Richard-Dang,
blakecduncan,
brg8,
florrdv,
inakov,
jakehobbs,
niveda-krish and
thebrianchen
as code owners
September 27, 2026 19:15
This was referenced Sep 27, 2026
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.
Problem
AlchemyRestClient.request()calls barefetch()with nosignal, andAlchemyRestClientParamsexposes notimeout/AbortSignaloption — consumers have no legitimate way to bound a request. If the upstream accepts the TCP connection but never responds (saturated LB, half-open keep-alive, captive middleware), the promise never settles.Reproduced against the published
@alchemy/common@5.2.7dist and againstmainsource with a local never-replying server:timeout: 3000(after)FetchError: The operation was aborted due to timeoutat 3002msThe JSON-RPC sibling already has this protection —
alchemy.tswraps viem'shttp()transport, which appliestimeout ?? 10_000via an internal AbortSignal. The REST client is the unprotected sibling.Fix
AlchemyRestClientParamsgains optionaltimeout(default10_000, matching the viem http transport default) andsignal(takes precedence when provided).request()appliesthis.signal ?? AbortSignal.timeout(this.timeout)to every fetch; aborts surface through the existingFetchErrorpath — no new error type, no behavior change for healthy upstreams.Verification
tsc --noEmit: no new errors vs clean main (5 pre-existing test-mock errors unchanged).FetchErrorat the configured timeout.index.ts; this hardens the surface before it graduates).PR-Codex overview
This PR introduces enhancements to the
AlchemyRestClient, adding support for request timeouts and abort signals to improve error handling and prevent indefinite hanging during requests.Detailed summary
timeoutproperty to specify request timeout in milliseconds.signalproperty to allow anAbortSignalfor request cancellation.timeoutandsignalparameters.requestmethod to use thetimeoutandsignalfor aborting requests.