Skip to content

fix: prevent infinite provider alternation when all providers return empty payment methods#28586

Draft
saustrie-consensys wants to merge 2 commits intomainfrom
fix/provider-alternation-loop-sol
Draft

fix: prevent infinite provider alternation when all providers return empty payment methods#28586
saustrie-consensys wants to merge 2 commits intomainfrom
fix/provider-alternation-loop-sol

Conversation

@saustrie-consensys
Copy link
Copy Markdown
Contributor

Description

When a user selects a token (e.g. SOL) where multiple providers claim static support via supportedCryptoCurrencies but all return empty payment methods from the API, the auto-switch effect in BuildQuote enters an infinite loop — cycling between providers every ~370ms.

  1. What is the reason for the change? The isTokenUnavailable effect silently switches to the next provider that statically supports the token, but never checks whether that candidate was already tried. When all candidates fail, it cycles back to the first one endlessly.

  2. What is the improvement/solution? Track which providers have already been attempted for the current token via a ref (triedProvidersRef). Skip already-tried providers in the providers.find() call. Once all candidates are exhausted, fall through to the Token Not Available modal. The set resets when the token changes.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3435

Manual testing steps

Feature: Provider auto-switch does not loop infinitely

  Scenario: User selects a token where all providers return empty payment methods
    Given the user is on the Build Quote screen
    And the provider was auto-selected by the system (not manually chosen)
    And the user is in US-CA region

    When the user changes the buy token from ETH to SOL
    Then the system tries each provider that claims SOL support at most once
    And after exhausting all candidates, the Token Not Available modal is shown
    And the provider does NOT alternate rapidly between Robinhood and Moonpay

  Scenario: User selects a token where an alternative provider has payment methods
    Given the user is on the Build Quote screen
    And the provider was auto-selected by the system

    When the user changes to a token unsupported by the current provider
    And another provider supports the token with valid payment methods
    Then the system silently switches to that provider
    And no modal is shown

Screenshots/Recordings

Before

https://www.loom.com/share/ef3f1307805646478e9e6ae3aa8a088a

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@saustrie-consensys saustrie-consensys added the team-money-movement issues related to Money Movement features label Apr 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@github-actions github-actions bot added the size-M label Apr 9, 2026
…empty payment methods

When a user selects a token (e.g. SOL) that multiple providers claim to
support via supportedCryptoCurrencies but none return valid payment methods,
the auto-switch effect in BuildQuote cycles endlessly between providers.
This tracks which providers have already been attempted for the current
token so they are skipped on subsequent runs, allowing the effect to fall
through to the Token Not Available modal once all candidates are exhausted.

Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3435
…lash

Change the auto-switch guard from a single-attempt boolean to a Set that
tracks every provider already tried for the current token.  This lets the
effect exhaust all candidates (matching the design intent of finding the
right provider for the user) while still preventing the infinite loop.

Additionally, suppress the "Powered by {provider}" text whenever
providerAutoSelected && isTokenUnavailable so the user does not see
the provider name flash as each candidate is probed.
@saustrie-consensys saustrie-consensys force-pushed the fix/provider-alternation-loop-sol branch from c60ec98 to 7c5114c Compare April 9, 2026 09:21
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - draft PR

All E2E tests pre-selected.

View GitHub Actions results

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

E2E Fixture Validation — Schema is up to date
16 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 9, 2026

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

Labels

size-M team-money-movement issues related to Money Movement features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant