Skip to content

feat(predict): cp-7.60.2 add auto-refresh polling when country is missing - #23513

Merged
caieu merged 2 commits into
mainfrom
predict/geoblock-hotfix
Dec 2, 2025
Merged

caieu merged 2 commits into
mainfrom
predict/geoblock-hotfix

Conversation

@caieu

@caieu caieu 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, 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.

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

@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-predict Predict team label Dec 2, 2025
@github-actions github-actions Bot added the size-M label Dec 2, 2025
@caieu
caieu marked this pull request as ready for review December 2, 2025 01:11
kevinbluer
kevinbluer previously approved these changes Dec 2, 2025

@kevinbluer kevinbluer left a comment

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.

LGTM (other than the bugbot comment re the comment)

@caieu
caieu enabled auto-merge December 2, 2025 02:08
@github-actions

github-actions Bot commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePredictions
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

The changes are focused on the Predict feature's eligibility checking mechanism, specifically:

  1. Core functionality change: Modified the debounce interval from 60 seconds to 100ms - a 600x reduction that significantly changes timing behavior
  2. New polling mechanism: Added automatic retry logic (up to 3 attempts every 2 seconds) when country data is missing from eligibility checks
  3. Critical path: The usePredictEligibility hook is used by usePredictActionGuard, which gates access to predict features based on geo-eligibility

Why SmokePredictions is selected:

  • The changes directly affect geo-restriction handling, which has dedicated E2E tests in e2e/specs/predict/predict-geo-restriction.spec.ts
  • This is a user-facing behavioral change that affects when and how often eligibility checks occur
  • The new auto-refresh polling adds complexity that should be validated in real app scenarios
  • Multiple predict E2E test files exist that cover different predict flows

Why Medium risk:

  • The changes are well-tested with 11 new unit test cases covering the polling logic
  • Changes are isolated to the Predict feature domain
  • However, the timing changes (debounce reduction) and new retry logic could have unexpected interactions with real network conditions and app state transitions
  • The hook is used in critical decision-making for feature access

Why not other tags:

  • The changes are entirely within the Predict feature scope
  • No changes to core wallet, network, accounts, or other feature domains
  • Unit tests provide good coverage but E2E validation is needed for real-world timing and state management scenarios

The confidence is 85% because the scope is clear and focused on Predict, but the timing behavior changes warrant real-world validation through E2E tests.

View GitHub Actions results

@kevinbluer
kevinbluer self-requested a review December 2, 2025 02:50
@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2025

Copy link
Copy Markdown

@caieu
caieu added this pull request to the merge queue Dec 2, 2025
Merged via the queue into main with commit a9cb801 Dec 2, 2025
157 of 161 checks passed
@caieu
caieu deleted the predict/geoblock-hotfix branch December 2, 2025 04:01
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 2, 2025
@metamaskbot metamaskbot added the release-7.62.0 Issue or pull request that will be included in release 7.62.0 label Dec 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.62.0 Issue or pull request that will be included in release 7.62.0 size-M team-predict Predict team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: geoblock_check timing out on some locations causing missing country data

3 participants