DataHub Docs
DataHubLearnCommunity
  • ๐Ÿ‘‹Welcome to Figment Docs
  • ๐ŸšฉIntroduction
    • ๐Ÿš€Why Build on Web 3?
    • ๐Ÿ’ปWhat is DataHub?
  • ๐Ÿ“–DataHub Guides
    • ๐Ÿ“DataHub Products
      • Transaction Search API
      • Staking API
    • ๐ŸญDataHub Infrastructure
    • ๐ŸGet Started With DataHub
    • ๐ŸšจQuotas & Rate Limits
    • ๐Ÿ’กDashboard how-tos
      • Configuring CORS whitelist
  • ๐Ÿ“šNetwork Documentation
    • ๐Ÿ”ญNetwork Guide
    • ๐Ÿ…ฐ๏ธArbitrum
      • ๐ŸŽฎRPC & REST API
    • ๐Ÿ”๏ธAvalanche
      • ๐ŸŽฎRPC & REST API
        • Avalanche Indexer API
    • ๐Ÿ’ Binance Smart Chain
      • ๐ŸŽฎRPC & REST API
    • ๐Ÿ’ฐCelo
      • ๐Ÿ’ผCELO Wallet
      • ๐ŸŽฎRPC & REST API
    • โžฐCentrifuge
      • ๐ŸŽฎRPC & REST API
    • ๐ŸŒŒCosmos
      • ๐ŸŽฎRPC & REST API
      • ๐ŸŽŠEnriched APIs
        • Transaction Search
        • Rewards API
    • ๐Ÿ’ŽEthereum
      • ๐ŸŽฎRPC & REST API
    • ๐ŸงŠFantom
      • ๐ŸŽฎRPC & REST API
    • ๐ŸฆKusama
      • ๐ŸŽฎRPC & REST API
    • ๐Ÿ“ฑMina
      • ๐ŸŽฎRPC & REST API
        • Indexer API Documentation
        • Query Mina GraphQL API
    • ๐ŸŒˆNEAR
      • ๐ŸŽฎRPC & REST API
      • ๐ŸŽŠEnriched APIs
        • Indexer API
      • ๐Ÿ’ผNEAR Wallet
    • ๐Ÿ๏ธOasis
      • ๐ŸŽฎRPC & REST API
        • Oasis REST API
    • ๐ŸงชOsmosis
      • ๐ŸŽฎRPC & REST API
    • ๐ŸกPolkadot
      • ๐ŸŽฎRPC & REST API
      • ๐ŸŽŠEnriched APIs
        • Indexer API
        • Transaction Search
    • โ›ฝPolygon (Matic)
      • ๐ŸŽฎRPC & REST API
    • ๐Ÿ”‹Solana
      • ๐ŸŽฎRPC & REST API
    • ๐Ÿ“šExtra Guides
      • Blockchain Fundamentals
      • Docker Setup for Windows
      • Troubleshooting CORS Errors on DataHub
      • 5XX Retry Logic Best Practices
        • 5XX Retry Logic Best Practices - NodeJS
        • 5XX Retry Logic Best Practices - Python
        • 5XX Retry Logic Best Practices - Ruby
        • 5XX Retry Logic Best Practices - Go
      • Setting up a fresh JavaScript Project with dotenv
      • Getting started with dotenv and .env files
      • Rust Learning Resources
      • Setup Solana BPF Toolchain on Windows
      • Figment Learn Pathway Troubleshooting
  • ๐Ÿค”Other
    • ๐ŸงพGlossary
    • ๐Ÿ—ณ๏ธSupport
  • ๐Ÿ”—Terms & Conditions
    • Terms of Use
    • Terms & Conditions DataHub
    • Privacy Policy
    • Contributor Terms
Powered by GitBook
On this page
  • Introduction
  • The basics of a retry

Was this helpful?

  1. Network Documentation
  2. Extra Guides

5XX Retry Logic Best Practices

Review best practices to deal with 5XX errors

Introduction

Since DataHub is a proxy that passes through errors from full node software, our users will need to adopt defensive strategies for interacting with the API.

We are making it easy for our users to do the right thing and providing examples of pseudo-code to copy/paste.

For Example:

tries = 3
begin
  r = RestClient.get(...)
rescue
  tries -= 1
  retry if tries > 0
end

The basics of a retry

To decide when to retry a request, we need to consider what to look for. There are a handful of HTTP status codes that you can check against. This will let your retry logic differentiate between a failed request that is appropriate to retryโ€”like a gateway errorโ€”and one that isn'tโ€”like a 404. In our examples, we will use 408, 500, 502, 503, 504, 522, and 524.

The next consideration we want is how often to retry. We will start with a delay, then increase it each additional time. This is a concept known as "back-off". The time between requests will grow with each attempt. Finally, we'll also need to decide how many attempts to make before giving up.

Here's an example of the logic we'll be using in pseudo-code:

  • If total attempts > attempts, continue

  • if status code type matches, continue

  • if (now - delay) > last attempt, try request

  • else, return to the start

Let's explore the best practices for NodeJs, Pyhton, Ruby, and Go:

PreviousTroubleshooting CORS Errors on DataHubNext5XX Retry Logic Best Practices - NodeJS

Last updated 3 years ago

Was this helpful?

๐Ÿ“š
๐Ÿ“š
5XX Retry Logic Best Practices - NodeJS
5XX Retry Logic Best Practices - Python
5XX Retry Logic Best Practices - Ruby
5XX Retry Logic Best Practices - Go