Skip to content

feat(providers): add configurable request timeouts to RPC providers - #437

Merged
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
subheeksh5599:feat/rpc-request-timeouts
Jul 29, 2026
Merged

feat(providers): add configurable request timeouts to RPC providers#437
Lakes41 merged 1 commit into
Adamantine-guild:mainfrom
subheeksh5599:feat/rpc-request-timeouts

Conversation

@subheeksh5599

Copy link
Copy Markdown
Contributor

Closes #424

What

Added configurable per-request timeouts to both RPC providers, with timeout tracking surfaced through the health tracker for adaptive provider scoring.

Changes

provider.types.ts

  • Added WebSocketProviderConfig with requestTimeoutMs option (default 10s)
  • Added SubscribableContractProvider, TransferEvent, TransferCallback types
  • These were imported but never defined — the build was relying on fallback typing

webSocketProvider.ts

  • Replaced hardcoded 30s timeout with configurable requestTimeoutMs from constructor config
  • Default: 10_000ms (matching SDK defaultTimeoutMs)
  • Socket is NOT closed on timeout — only the individual pending request is rejected
  • Error is typed TIMEOUT (existing error code)

healthTracker.ts

  • Added recordTimeout() — tracks timeout failures separately from other transient failures
  • Added timeoutCount() — exposes per-URL timeout count for adaptive provider scoring
  • Delegates to recordFailure for circuit-breaker logic

adaptive.types.ts

  • Added timeoutCount as optional field on UrlHealth

What already existed (no changes needed)

feature status
timeoutMs in RequestOptions ✅ already flows to HttpClient
defaultTimeoutMs in SDK config (10s)
HttpClient AbortController timeout
jsonRpcProvider passes timeoutMs through
Typed GuildPassTimeoutError
per-request timeout tests ✅ existing in tests/per-request-timeout.test.ts

Build & Tests

pnpm build  → success
pnpm test:run → 71 files, 1421 tests, all passing

- provider.types.ts: added WebSocketProviderConfig, SubscribableContractProvider,
  TransferEvent, TransferCallback types with requestTimeoutMs option
- webSocketProvider.ts: replaced hardcoded 30s timeout with configurable
  requestTimeoutMs (default 10s), stored from constructor config
- healthTracker.ts: added recordTimeout() tracking timeout-specific failures
  independently from other transient failures for adaptive provider scoring
- adaptive.types.ts: added timeoutCount to UrlHealth for timeout frequency
  tracking
- jsonRpcProvider.ts: already passes timeoutMs through to HttpClient via
  RequestOptions — no changes needed (existing default 10s in SDK config)

Closes Adamantine-guild#424
@subheeksh5599
subheeksh5599 marked this pull request as ready for review July 29, 2026 04:56
@Lakes41
Lakes41 merged commit d8e0d56 into Adamantine-guild:main Jul 29, 2026
8 checks passed
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.

Add configurable request timeouts to RPC providers

2 participants