Skip to content

fix: validate per-request timeoutMs in fetch client - #557

Merged
David-patrick-chuks-02 merged 1 commit into
Lilly-Protocol:mainfrom
kramsg1405:fix-request-timeout-validation
Sep 6, 2026
Merged

fix: validate per-request timeoutMs in fetch client#557
David-patrick-chuks-02 merged 1 commit into
Lilly-Protocol:mainfrom
kramsg1405:fix-request-timeout-validation

Conversation

@kramsg1405

Copy link
Copy Markdown
Contributor

Summary

This PR adds validation for the per-request timeoutMs option in the fetch HTTP client.

Problem

client.request({ ..., timeoutMs: -1 }) and NaN/string values would be passed through without validation, leading to silently-firing or never-firing timers instead of clear error messages.

Solution

Validate request.timeoutMs before the request loop starts:

  • Reject negative, NaN, Infinity, and non-number values with a clear LilyConfigError
  • Allow 0 (documented opt-out for disabling timeout)
  • Allow positive finite numbers

Mirrors the existing config-level timeoutMs validation in resolve-config.ts.

Testing

Added comprehensive unit tests in tests/request-timeout-validation.test.ts:

  • Rejects negative values
  • Rejects NaN
  • Rejects Infinity
  • Rejects string values
  • Accepts 0 (opt-out)
  • Accepts positive values
  • Uses config timeoutMs when request timeoutMs is undefined

Related Issue

Closes #446

Payment

Wallet: 0x047b2A7fc72862a0e3E772eb53b19d35929BEd46 (Base/EVM, USDC or BUSD BEP20)

- Reject negative, NaN, Infinity, and non-number timeoutMs values
- Allow 0 (opt-out) and positive values
- Mirror config-level validation message
- Add comprehensive unit tests

Addresses bounty: Lilly-Protocol#446
Payment address: 0x047b2A7fc72862a0e3E772eb53b19d35929BEd46 (Base/EVM, USDC/BUSD BEP20)
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.

[Bounty: $100] Validate per-request timeoutMs values in the fetch transport

2 participants