Skip to content

Add configurable request timeouts to RPC providers #424

Description

@Lakes41

Difficulty: Intermediate
Type: Feature
Recommended labels (if available in this repo): enhancement, reliability, sdk

Background

src/contracts/providers/jsonRpcProvider.ts and webSocketProvider.ts wrap the underlying RPC transports, but neither currently exposes a configurable per-request timeout — a hung RPC connection can block an access check indefinitely.

Problem

Without a timeout, a slow or unresponsive RPC endpoint causes access checks to hang rather than failing fast (which would allow the adaptive provider or caller to fail over or surface a clear error).

Expected Outcome

Both providers accept a requestTimeoutMs config option; requests exceeding the timeout are aborted and rejected with a typed TimeoutError.

Suggested Implementation

Use AbortController (or the transport library's native timeout support) to enforce the timeout in both providers. Ensure the WebSocket provider's timeout doesn't tear down the underlying persistent connection, only the individual pending request. Surface timeouts through healthTracker.ts so the adaptive provider can factor timeout frequency into its health scoring.

Acceptance Criteria

  • requestTimeoutMs is configurable via networkConfig.ts / sdkConfig.ts, with a sensible default
  • Timed-out requests reject with a typed TimeoutError, not a generic error
  • WebSocket provider timeout does not close the underlying socket connection
  • Unit tests simulate a hung request and verify timeout behavior for both providers
  • pnpm test:run passes

Likely Affected Files/Directories

  • src/contracts/providers/jsonRpcProvider.ts
  • src/contracts/providers/webSocketProvider.ts
  • src/contracts/providers/healthTracker.ts
  • src/config/networkConfig.ts

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesOfficial Campaign | FWC26Official FWC26 campaign issue — eligible for campaign scoring and rewards

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions