Skip to content

portfolio-v2: a token/metrics upstream failure discards engine balances that were already fetched #65

Closed

Description

@feruzm

Summary

In FetchEngineTokensWithBalance (Handlers/WalletApi.Engine.cs) the balances call succeeds first, then FetchEngineTokens and FetchEngineMetrics run together:

var balances = await FetchEngineBalances(username);
...
var tokensTask  = FetchEngineTokens(symbols);
var metricsTask = FetchEngineMetrics(symbols);
var unclaimedTask = WithTimeout(FetchEngineRewards(username), EngineRewardsTimeoutMs, new JsonArray());
await Task.WhenAll(tokensTask, metricsTask, unclaimedTask);

If either tokensTask or metricsTask throws after exhausting failover, the outer catch returns an empty array and the entire engine layer disappears — including balances that were already fetched successfully.

Why it matters

The three calls are not equally important:

  • balances — the actual user data.
  • tokens — display metadata (name, precision, icon).
  • metrics — market data, used only for fiat valuation.

A metrics outage currently produces the same user-visible result as a total Hive-Engine outage: no tokens in the wallet at all. Degrading to "balances without a fiat value" is strictly better than showing nothing.

The rewards leg already models this correctly — it is capped by EngineRewardsTimeoutMs and degrades to an empty array rather than failing the layer. Tokens and metrics should degrade the same way.

Proposed fix

Give tokensTask and metricsTask the same treatment as rewards: fall back to an empty array on failure so ConvertEngineToken receives nulls for the optional inputs, and the balance rows still render. Keep the outer catch for the balances call, which is the only genuinely required leg.

Add a test covering: balances succeed, metrics fail -> engine layer still returns one row per balance.

Not the cause of the currently-reported missing balances (see the metadata-node issue), but it is the remaining path where good data is thrown away because an optional enrichment failed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions