Skip to content

fix: handle rate limit (429) and timeout errors in fetchJson - #1

Open
ygd58 wants to merge 1 commit into
RitualChain:mainfrom
ygd58:fix/fetch-error-handling-rate-limit
Open

fix: handle rate limit (429) and timeout errors in fetchJson#1
ygd58 wants to merge 1 commit into
RitualChain:mainfrom
ygd58:fix/fetch-error-handling-rate-limit

Conversation

@ygd58

@ygd58 ygd58 commented Jul 1, 2026

Copy link
Copy Markdown

Summary

Two error handling gaps in fetchJson inside tool/market-tool.ts:

Problems

1. CoinGecko 429 rate limit — When the API returns HTTP 429, the existing code throws a raw error like Market data request failed (429 Too Many Requests). This is confusing for end users who have no context on what to do.

2. Timeout AbortError — When the request times out, AbortController fires and throws an AbortError. This was not caught separately, so it surfaced as an unhandled error instead of a clear timeout message.

Fix

  • ✅ Detect res.status === 429 and throw a user-friendly rate limit message
  • ✅ Catch AbortError by name and throw a descriptive timeout message including the configured timeout duration

- Add explicit 429 handling with a clear user-facing message instead
  of leaking raw HTTP error text when CoinGecko rate-limits the client
- Catch AbortError separately so timeout failures surface a descriptive
  message rather than a generic network error
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

@ygd58 is attempting to deploy a commit to the 0xBuns Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant