Skip to content

chore: ohlcv reduce initial delay cp-7.78.0#30292

Merged
sahar-fehri merged 5 commits into
mainfrom
chore/ohlcv-reduce-initial-delay
May 18, 2026
Merged

chore: ohlcv reduce initial delay cp-7.78.0#30292
sahar-fehri merged 5 commits into
mainfrom
chore/ohlcv-reduce-initial-delay

Conversation

@sahar-fehri

@sahar-fehri sahar-fehri commented May 18, 2026

Copy link
Copy Markdown
Contributor

Description

Problem

Chart data took ~9-10 seconds to display after navigating to token details. Performance logs showed it takes approximately 9.4 seconds from WebSocket subscription until the first bar update arrives from the server.

Solution

Implemented immediate REST API polling to provide data while waiting for the first WebSocket update:

  1. Reduced staleness threshold from 10s to 5s
  2. Added immediate data fetch via REST API right after WebSocket subscription

Timeline Observed

T=0ms     - Subscribe to WebSocket
T=~300ms  - First REST data arrives (immediate!)
T=5s      - Second REST poll (WebSocket not ready yet)
T=9.4s    - First WebSocket update arrives, REST polling stops
T=14.4s+  - WebSocket continues with regular updates (~5s intervals)

Changelog

CHANGELOG entry: OHLCV chart data now loads in ~300ms via REST API while establishing WebSocket connection, reducing initial load time from 9.4s to 300ms.

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

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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

Medium Risk
Changes chart data fetching timing by triggering immediate REST polls and a shorter staleness threshold, which could increase network traffic or cause unexpected polling behavior if timing assumptions are wrong.

Overview
Reduces perceived OHLCV chart load time by polling the /latest REST endpoint immediately after a successful WebSocket subscribe, instead of waiting for the first WS bar.

Shortens the WS staleness threshold from 10s to 5s, tweaks stale detection to use >=, and adds basic numeric validation in fetchLatestBar to drop malformed REST responses. Tests are updated to reflect the new timing and the additional initial REST fetch (many cases now expect two fetch calls: immediate + staleness/chain-down).

Reviewed by Cursor Bugbot for commit a3d5c11. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

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.

@sahar-fehri sahar-fehri changed the title Chore/ohlcv reduce initial delay chore: ohlcv reduce initial delay May 18, 2026
@sahar-fehri sahar-fehri marked this pull request as ready for review May 18, 2026 08:58
@sahar-fehri sahar-fehri changed the title chore: ohlcv reduce initial delay chore: ohlcv reduce initial delay cp-7.78.0 May 18, 2026
bergarces
bergarces previously approved these changes May 18, 2026

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

Reviewed by Cursor Bugbot for commit 7ec1e9a. Configure here.

Comment thread app/components/UI/Charts/AdvancedChart/useOHLCVRealtime.ts
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 95%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are entirely confined to the useOHLCVRealtime hook and its unit test file. This hook handles real-time OHLCV (candlestick) chart data via WebSocket with HTTP polling fallback, used only in Price.advanced.tsx (the advanced price chart component).

Changes made:

  1. Reduced staleness threshold from 10s to 5s (more aggressive fallback to HTTP polling)
  2. Added data validation for timestamp and close fields before returning bar data
  3. Changed > to >= in staleness check (boundary condition fix)
  4. Added immediate HTTP poll after WebSocket subscribe for faster initial data

These are internal bug fixes/improvements to a chart data streaming hook. The hook is:

  • Only imported by Price.advanced.tsx and its test file
  • Mocked in all unit tests that use it
  • Not connected to any wallet flows, transactions, accounts, networks, confirmations, or navigation
  • Not part of any E2E test flows (no Detox tests cover this chart component directly)

No E2E test tags are warranted because:

  • No existing E2E tests cover the OHLCV chart functionality
  • The changes don't affect any shared components (TabBar, modals, confirmations, browser)
  • The risk is isolated to chart data display timing, which is a non-critical UI enhancement
  • Unit tests adequately cover the changed behavior

Performance Test Selection:
The changes are to a WebSocket/HTTP polling hook for chart data. While it involves data fetching, the changes are minor timing adjustments (staleness threshold) and data validation. This does not impact account list rendering, onboarding, login, swaps, app launch, asset loading, predictions, or perps performance in any measurable way. The hook runs in the background for chart display only.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@sahar-fehri sahar-fehri added this pull request to the merge queue May 18, 2026
Merged via the queue into main with commit cd875d0 May 18, 2026
149 of 158 checks passed
@sahar-fehri sahar-fehri deleted the chore/ohlcv-reduce-initial-delay branch May 18, 2026 13:56
@github-actions github-actions Bot locked and limited conversation to collaborators May 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants