Skip to content

chore(runway): cherry-pick feat(predict): cp-7.60.2 add auto-refresh polling when country is missing - #23518

Merged
joaoloureirop merged 1 commit into
release/7.60.2from
runway-cherry-pick-7.60.2-1764648245
Dec 2, 2025
Merged

joaoloureirop merged 1 commit into
release/7.60.2from
runway-cherry-pick-7.60.2-1764648245

Conversation

@runway-github

@runway-github runway-github Bot commented Dec 2, 2025 •

Copy link
Copy Markdown
Contributor

Description

Add automatic polling mechanism to usePredictEligibility hook that
refreshes eligibility when no country is returned in the response.

Changes:

  • Add sequential polling pattern (wait for response → wait interval →
    poll again)
  • Poll every 2 seconds until country is returned or component unmounts
  • Continue polling even if individual requests fail
  • Stop polling automatically when country becomes available
  • Add comprehensive tests for the new polling behavior

This ensures users get their country data even if the initial
eligibility check doesn't return it, improving the reliability
of the Predict feature's geo-restriction handling.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

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.

Note

Adds sequential auto-refresh polling to usePredictEligibility when country is missing (2s interval, 3 retries) and reduces auto-refresh debounce to 100ms, with comprehensive tests.

  • Predict Eligibility Hook (usePredictEligibility):
    • Adds sequential auto-refresh polling when country is missing: wait for response → wait 2000ms → retry, up to 3 retries.
    • Stores refreshEligibility in a useRef to avoid effect restarts.
    • Exposes country via memoized selector and uses it to control polling.
    • Reduces auto-refresh debounce from 60000ms to 100ms.
  • Tests (usePredictEligibility.test.ts):
    • Update debounce expectations to 100ms.
    • Add test suite for missing-country polling: start, interval retries, stop at max retries, error handling, unmount cleanup, and sequential polling behavior.
    • Ensure app state transition and race-condition cases respect new debounce and polling logic.

Written by Cursor Bugbot for commit 831dd0e. This will update automatically on new commits. Configure here.

a9cb801

…polling when country is missing (#23513)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

Add automatic polling mechanism to usePredictEligibility hook that
refreshes eligibility when no country is returned in the response.

Changes:
- Add sequential polling pattern (wait for response → wait interval →
poll again)
- Poll every 2 seconds until country is returned or component unmounts
- Continue polling even if individual requests fail
- Stop polling automatically when country becomes available
- Add comprehensive tests for the new polling behavior

This ensures users get their country data even if the initial
eligibility check doesn't return it, improving the reliability
of the Predict feature's geo-restriction handling.

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry: null

## **Related issues**

Fixes:

## **Manual testing steps**

```gherkin
Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]
```

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds sequential auto-refresh polling to `usePredictEligibility` when
`country` is missing, reduces debounce to 100ms, and updates tests
accordingly.
> 
> - **Predict Eligibility Hook (`usePredictEligibility`)**:
> - Adds sequential auto-refresh polling when
`eligibility[providerId].country` is missing.
> - Polls every `2000ms` up to `3` retries; stops on country
availability or unmount; logs failures and retry limits.
>   - Introduces `useRef` to stabilize `refreshEligibility` in effects.
>   - Reduces debounce interval to `100ms` for automatic refreshes.
> - **Tests (`usePredictEligibility.test.ts`)**:
>   - Update debounce expectations to `100ms` and related timings.
> - Add comprehensive tests for missing-country polling: start/interval,
max retries, error handling, cleanup on unmount, and sequential polling
behavior.
> - Ensure scenarios for app state transitions, race prevention, manual
refresh, and error logging reflect new timings and polling logic.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9ad7a9c. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@github-actions

github-actions Bot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

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.

@metamaskbot metamaskbot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Dec 2, 2025
@github-actions

github-actions Bot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeCore, SmokeConfirmationsRedesigned, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeTrade, SmokeWalletPlatform, SmokeWalletUX, SmokeAssets, SmokeSwaps, SmokeStake, SmokeCard, SmokeNotifications, SmokeRewards, SmokePerps, SmokeRamps, SmokeMultiChainPermissions, SmokeAnalytics, SmokeMultiChainAPI, SmokePredictions
  • Risk Level: high
  • AI Confidence: %
click to see 🤖 AI reasoning details

Fallback: AI analysis did not complete successfully. Running all tests.

View GitHub Actions results


// Minimum time between automatic eligibility refreshes (1 minute)
const DEBOUNCE_INTERVAL_MS = 60000;
const DEBOUNCE_INTERVAL_MS = 100;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Debounce interval reduced from 1 minute to 100ms

The DEBOUNCE_INTERVAL_MS constant was changed from 60000 (1 minute) to 100 (100 milliseconds), while the comment on line 18 still says "Minimum time between automatic eligibility refreshes (1 minute)". This mismatch indicates the production value was accidentally reduced to accommodate test timing. With a 100ms debounce instead of 60 seconds, eligibility API calls could occur 600x more frequently than intended when the app transitions between foreground states, potentially causing unnecessary API load, rate limiting issues, and degraded mobile performance.

Fix in Cursor Fix in Web

@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2025

Copy link
Copy Markdown

@joaoloureirop
joaoloureirop enabled auto-merge (squash) December 2, 2025 14:46
@joaoloureirop
joaoloureirop merged commit 8872250 into release/7.60.2 Dec 2, 2025
73 of 75 checks passed
@joaoloureirop
joaoloureirop deleted the runway-cherry-pick-7.60.2-1764648245 branch December 2, 2025 14:46
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 2, 2025
@metamaskbot metamaskbot added the release-7.60.2 Issue or pull request that will be included in release 7.60.2 label Dec 2, 2025
@metamaskbot

Copy link
Copy Markdown
Collaborator

No release label on PR. Adding release label release-7.60.2 on PR, as PR was cherry-picked in branch 7.60.2.

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

Labels

release-7.60.2 Issue or pull request that will be included in release 7.60.2 team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants