Skip to content

feat(timeout): bound every external request with one shared default timeout - #671

Open
aladuru001 wants to merge 1 commit into
Sub-Rosa-Issue:mainfrom
aladuru001:fix/534-shared-rpc-timeout
Open

aladuru001 wants to merge 1 commit into
Sub-Rosa-Issue:mainfrom
aladuru001:fix/534-shared-rpc-timeout

Conversation

@aladuru001

@aladuru001 aladuru001 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

SDK, keeper, appraisal and Drand clients each had their own timeout or none, so a hung peer could stall a component indefinitely. This adds one shared default and applies it.

  • @sub-rosa/time now exports DEFAULT_REQUEST_TIMEOUT_MS (10 000 ms), resolveRequestTimeoutMs, RequestTimeoutError and fetchWithTimeout. Overrides must be integers in 100–300 000 ms; 0, NaN and out-of-range values throw instead of silently disabling the bound.
  • SubRosaClient passes the timeout to every rpc.Server it builds (new rpcTimeoutMs). The keeper reaches RPC through the SDK, so it inherits this.
  • mainnet-readiness RPC servers use the default; StatusClient now references the shared constant (same 10 s value).
  • createPaidFetch bounds both the probe and the paid retry (new requestTimeoutMs).
  • drand-tools quicknet requests are bounded. This adds @sub-rosa/time as a workspace dependency (lockfile updated; pnpm install --frozen-lockfile passes).
  • Documented in docs/INTEGRATION.md ("External request timeouts") and the keeper README.

The timer covers connecting and receiving response headers. It does not bound a body that stalls after headers; confirmTimeout remains a separate bound on finality polling.

Closes #534

Supply-chain review

  • No package scripts or dependencies changed — changed: services/drand-tools gains the in-repo workspace dependency @sub-rosa/time (workspace:*, no external package), and packages/time test script lists the new test file. No install or lifecycle scripts added.
  • No .vscode/, workflow, or other editor/config file changes.
  • No lockfile changes — changed: pnpm-lock.yaml has only the matching 3-line drand-tools → link:../../packages/time entry; verified with pnpm install --frozen-lockfile.
  • No binary or font asset changes.
  • I confirm no automatic task (such as preinstall/postinstall) was added.
  • I confirm no hidden executable payload was added.
  • Any changed executable or binary was reviewed by a maintainer (none changed).

Tests

  • packages/time/src/request-timeout.test.ts (8 tests, fake scheduler): default is 10 s, invalid overrides rejected, a hung request fails with RequestTimeoutError exactly at the deadline, per-call override, timer cleared on success and on failure, caller abort preserved, already-aborted signal, URL never in the error.
  • packages/sdk/src/errors.test.ts: rpcTimeoutMs validation.
  • services/appraisal-api/src/client.test.ts: a hung probe request times out; invalid requestTimeoutMs rejected.

Verification notes

I ran these on Windows with Node 20 (repo wants ≥22). The new tests pass. Existing failures are identical on an unmodified upstream/main checkout: in packages/sdk, src/client.test.ts (fails to load, 45 pre-existing tsc errors), ROUND_CONTRACT_ERRORS mapping coverage and KeeperStatusClient readiness ("errors never include keeper URL userinfo"). The unfiltered services/appraisal-api/src/client.test.ts times out locally on upstream/main too, so I ran only my two new tests there. Please rely on CI for the rest.

🤖 Generated with Claude Code

SDK, keeper, appraisal and Drand clients each had their own (or no)
request timeout, so a hung peer could stall a component indefinitely.

Add DEFAULT_REQUEST_TIMEOUT_MS (10s), resolveRequestTimeoutMs (integer,
100-300000ms; invalid values throw rather than disabling the bound),
RequestTimeoutError and fetchWithTimeout to @sub-rosa/time, and use them:

- SubRosaClient passes the timeout to every rpc.Server (new rpcTimeoutMs)
- mainnet-readiness RPC servers use the default
- StatusClient default now references the shared constant
- createPaidFetch bounds the probe and paid retry (new requestTimeoutMs)
- drand-tools quicknet requests are bounded

Documented in docs/INTEGRATION.md and the keeper README.

Closes Sub-Rosa-Issue#534

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@drips-wave

drips-wave Bot commented Nov 24, 2026

Copy link
Copy Markdown

@aladuru001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

security(high/easy): bound every external RPC request with one timeout

1 participant