Resiliency
Wayfinder includes built-in resiliency features:
- Gateway retry: If a gateway returns a 5xx error or a network failure occurs, Wayfinder selects a gateway again and retries, up to 3 attempts in total. Each new selection passes the gateways that already failed as
exclude, so the built-in strategies pick a different gateway when they have one:RandomRoutingStrategyandRoundRobinRoutingStrategyskip the failed gateways,FastestPingRoutingStrategypings the failed gateways only when no other gateway answers,PreferredWithFallbackRoutingStrategymoves to its fallback, andSimpleCacheRoutingStrategyreplaces a cached gateway that failed. When every gateway in the pool has already failed, these strategies return one of the failed gateways rather than throwing, so it is tried again.StaticRoutingStrategyhas one gateway, so every attempt goes to it. A custom strategy that ignoresexcludecan return the same gateway again. Client errors (4xx) are returned immediately without retry. - Fetch timeouts: All outbound requests include configurable timeouts — 10s for metadata (HEAD, peer list), 30s for data retrieval — to prevent indefinite hangs on slow or dead gateways.
- Gateway health checks:
PingRoutingStrategyverifies the selected gateway responds before routing to it. If it does not, it selects again with that gateway excluded. - Peer list retries:
TrustedPeersGatewaysProviderretries when a gateway returns an empty peer list, then fails loudly rather than silently yielding no gateways — and the default provider falls back to the trusted gateway so that failure degrades routing instead of stopping it. - Registry pagination failures are fatal:
NetworkGatewaysProviderretries a failed page and throws once retries are exhausted, rather than returning a partial registry. Becauselimitis applied after sorting, a partial read would return the wrong gateways rather than merely fewer. - Full-registry pagination:
NetworkGatewaysProviderreads the whole on-chain registry before applyinglimit, solimitselects the top-ranked gateways rather than whichever ones happened to come back first. It pages at the SDK maximum, so this is a single request for a registry of the current size.
How is this guide?