Skip to content

Conversation

Copy link

Copilot AI commented Oct 2, 2025

Problem

When RPC providers like Alchemy return errors (especially HTTP 429 rate limit errors), only the status code was logged without the detailed error message from the response body. This made debugging provider issues difficult.

Example of current logging:

HTTP error: 429 Too Many Requests

What the provider actually returns:

{
  "error": {
    "code": 429,
    "message": "Monthly capacity limit exceeded. Visit https://dashboard.alchemy.com/settings/billing to increase your capacity"
  }
}

Solution

Modified RelayError::RpcError to extract and display the detailed error message from JSON-RPC error responses when available.

New logging format:

RPC error: Monthly capacity limit exceeded. Visit https://dashboard.alchemy.com/settings/billing to increase your capacity (code: 429)

Changes

  • Modified src/error/mod.rs:

    • Changed RelayError::RpcError variant from #[error(transparent)] to use custom formatting
    • Added format_rpc_error() function that extracts error.message and error.code from JSON-RPC responses
    • Falls back to default formatting for transport-level errors (network issues, etc.)
  • Added comprehensive tests:

    • Test for Alchemy rate limit errors (HTTP 429)
    • Test for generic RPC execution errors
    • Verified error messages contain both the detailed message and error code

Benefits

Better debugging: Developers immediately see why the provider failed
Actionable information: Error messages often include links to provider dashboards
Consistent format: All RPC errors show detailed information when available
No breaking changes: Falls back gracefully for errors without detailed responses

Examples

Alchemy Rate Limit

Before: HTTP error: 429 Too Many Requests
After:  RPC error: Monthly capacity limit exceeded. Visit https://dashboard.alchemy.com/settings/billing... (code: 429)

Execution Reverted

Before: HTTP error: 400 Bad Request
After:  RPC error: execution reverted: insufficient balance for transfer (code: -32000)

This change directly addresses the need to avoid situations where the relay goes down due to provider issues and we cannot figure out the reason from the logs.

Fixes #[issue number]

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • arb1.arbitrum.io
    • Triggering command: /home/REDACTED/work/relay/relay/target/debug/deps/relay-0116f8e29f20dbc0 (dns block)
  • eu-central-mainnet.rpc.ithaca.xyz
    • Triggering command: /home/REDACTED/work/relay/relay/target/debug/deps/relay-0116f8e29f20dbc0 (dns block)
  • mainnet.optimism.io
    • Triggering command: /home/REDACTED/work/relay/relay/target/debug/deps/relay-0116f8e29f20dbc0 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Improve error logging for Alchemy rate limit (429) errors</issue_title>
<issue_description>## Problem

Alchemy rate limit errors (HTTP 429) only log the status code, not the detailed error message from the response body.

This is hard to debug.

Current log:

HTTP error: 429 Too Many Requests

Alchemy response body contains:

{"error": {"code": 429, "message": "Monthly capacity limit exceeded. Visit https://dashboard.alchemy.com/settings/billing..."}}

Location: https://github.com/ithacaxyz/relay/blob/main/src/chains.rs#L435

Parse and log the error.message field from JSON-RPC error responses.</issue_description>

<agent_instructions>what we want to do is to avoid a situation where it goes down because of a provider and we cannot figure out a reason</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #1444

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Improve error logging for Alchemy rate limit (429) errors feat: improve RPC error logging to show detailed provider messages Oct 2, 2025
Copilot AI requested a review from yongkangc October 2, 2025 09:00
Copilot finished work on behalf of yongkangc October 2, 2025 09:00
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.

Improve error logging for Alchemy rate limit (429) errors

2 participants