Skip to content

chore: Downgrade @tanstack/react-query to ^4.43.0#27964

Merged
FrederikBolding merged 5 commits into
mainfrom
fb/react-query-downgrade
Mar 26, 2026
Merged

chore: Downgrade @tanstack/react-query to ^4.43.0#27964
FrederikBolding merged 5 commits into
mainfrom
fb/react-query-downgrade

Conversation

@FrederikBolding

@FrederikBolding FrederikBolding commented Mar 26, 2026

Copy link
Copy Markdown
Member

Description

This PR downgrades @tanstack/react-query to ^4.43.0 to allow us to bring in shared tooling between extension and mobile for queries. This is a temporary measure until the extension gets to React 18, which is the minimum version for @tanstack/react-query@5.

Most of the breaking changes that impact our existing code is type related due to TError being unknown in v4. Additionally a couple of properties we use have been renamed between the two versions. The semantics of isLoading has also changed for enabled: false queries, but that can be recovered by using isFetching && isLoading This PR adjusts all of these.

Changelog

CHANGELOG entry: null

Related issues

https://consensyssoftware.atlassian.net/browse/WPC-445


Note

Medium Risk
Moderate risk because it downgrades a core data-fetching library and adjusts loading/polling semantics across multiple hooks, which could change UI states or caching behavior if any edge cases were missed.

Overview
Downgrades @tanstack/react-query from v5 to v4 (including lockfile updates) and updates the app’s QueryClient defaults to use v4’s cacheTime option.

Aligns hooks and tests with v4 API/behavior changes: replaces gcTime usage, updates keepPreviousData configuration, switches some status checks from isPending to isLoading, adds/propagates isFetching, and standardizes derived isLoading as isLoading && isFetching for disabled/manual queries (Card hooks, Ramp hooks, Predict query options, and related tests).

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

@metamaskbot metamaskbot added team-core-platform Core Platform team INVALID-PR-TEMPLATE PR's body doesn't match template labels Mar 26, 2026
@socket-security

socket-security Bot commented Mar 26, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​tanstack/​react-query@​5.90.20 ⏵ 4.43.0100 +110089 +2100 +4100

View full report

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.58%. Comparing base (62f6136) to head (64d6602).
⚠️ Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
app/components/UI/Card/hooks/useCardPinToken.ts 0.00% 1 Missing ⚠️
app/components/UI/Predict/queries/orderPreview.ts 0.00% 1 Missing ⚠️
app/components/UI/Predict/queries/unrealizedPnL.ts 0.00% 1 Missing ⚠️
...components/UI/Ramp/hooks/useRampsPaymentMethods.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #27964       +/-   ##
===========================================
- Coverage   82.56%   47.58%   -34.99%     
===========================================
  Files        4825     4839       +14     
  Lines      123955   124449      +494     
  Branches    27617    27734      +117     
===========================================
- Hits       102346    59220    -43126     
- Misses      14560    59901    +45341     
+ Partials     7049     5328     -1721     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@FrederikBolding FrederikBolding marked this pull request as ready for review March 26, 2026 12:01
@FrederikBolding FrederikBolding requested review from a team as code owners March 26, 2026 12:01
@FrederikBolding FrederikBolding force-pushed the fb/react-query-downgrade branch from 89c19f9 to cb3d691 Compare March 26, 2026 12:01
@github-actions github-actions Bot added the risk-high Extensive testing required · High bug introduction risk label Mar 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeCard, SmokePredictions, SmokeRamps, SmokeTrade, SmokeConfirmations, SmokeWalletPlatform
  • Selected Performance tags: @PerformancePredict
  • Risk Level: high
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR downgrades @tanstack/react-query from v5 to v4, which is a major version change with significant API differences. All the code changes are compatibility fixes to align with v4 APIs:

  1. gcTimecacheTime in ReactQueryService (v5 renamed cacheTime to gcTime)
  2. isPendingisLoading in Ramp hooks (v5 renamed isLoading to isPending for queries without data)
  3. isLoading && isFetching pattern in Card hooks (in v4, isLoading is true even when cached data exists; isFetching is needed to detect actual network requests)
  4. refetchInterval callback signature changed from (query) => query.state.data to (data) => data (v4 passes data directly)
  5. keepPreviousData: true option instead of placeholderData: keepPreviousData (v4 API)
  6. Explicit type parameters added to queryOptions<T, Error>() for v4 compatibility

Affected features:

  • Card: Multiple hooks changed affecting loading states, KYC status, delegation settings, registration, allowances, external wallet details, cashback wallet, pin token mutation - all Card UI flows could be affected
  • Predictions: All query options updated - balance, positions, activity, markets, order preview, unrealized PnL
  • Ramp: Payment methods and quotes loading state detection changed

Tag selection rationale:

  • SmokeCard: Directly affected - multiple Card hooks changed with loading state logic
  • SmokePredictions: Directly affected - all Predict query options updated for v4 compatibility
  • SmokeRamps: Directly affected - payment methods and quotes hooks changed
  • SmokeTrade: Required by SmokeCard (Add Funds uses swaps) and SmokePredictions (trading category)
  • SmokeConfirmations: Required by SmokeCard (Add Funds uses transactions) and SmokePredictions (on-chain transactions)
  • SmokeWalletPlatform: Required by SmokePredictions (Trending section) and SmokeRamps (wallet actions entry point)

The react-query downgrade is a high-risk change as it affects data fetching behavior across multiple features. Loading state changes could cause UI regressions (spinners not showing, premature data display, etc.).

Performance Test Selection:
The Predict queries have been updated for react-query v4 compatibility, including changes to keepPreviousData behavior and query options. This could affect how prediction market data is loaded and cached, potentially impacting the performance of the Predict feature. The @PerformancePredict tag covers prediction market list loading, market details, deposit flows, and balance display - all of which use the updated query options. Other performance areas (account list, login, swaps, launch, asset loading) are not directly affected by these changes.

View GitHub Actions results

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread app/components/UI/Card/hooks/useCardPinToken.ts
@github-actions

Copy link
Copy Markdown
Contributor

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

@sonarqubecloud

Copy link
Copy Markdown

@matallui matallui 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

@FrederikBolding FrederikBolding added this pull request to the merge queue Mar 26, 2026
Merged via the queue into main with commit 31b09da Mar 26, 2026
104 checks passed
@FrederikBolding FrederikBolding deleted the fb/react-query-downgrade branch March 26, 2026 20:19
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 26, 2026
@metamaskbot metamaskbot added the release-7.73.0 Issue or pull request that will be included in release 7.73.0 label Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template release-7.73.0 Issue or pull request that will be included in release 7.73.0 risk-high Extensive testing required · High bug introduction risk size-M team-core-platform Core Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants