Draft
Fix cache collision preventing API data load on data source switch#4
Conversation
The bug was that cache keys didn't include the dataSource parameter, causing cached mock data to be returned when switching to API mode (and vice versa). This prevented the chart from loading fresh API data after switching data sources. Fixed by including dataSource in cache key generation for both useStockData and useQuote hooks. Co-authored-by: rmoreirao <22824536+rmoreirao@users.noreply.github.com>
Co-authored-by: rmoreirao <22824536+rmoreirao@users.noreply.github.com>
Replaced arbitrary timeouts with proper wait strategies:
- Use waitForLoadState('networkidle') instead of fixed timeouts
- Add proper error handling for network state waits
- Wait for chart canvas visibility before proceeding
- Makes tests more reliable and faster
Co-authored-by: rmoreirao <22824536+rmoreirao@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix bug where chart is not loading data from API
Fix cache collision preventing API data load on data source switch
Jan 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cache keys in
useStockDataanduseQuoteomitted thedataSourceparameter. Switching from Mock to API returned cached mock data instead of fetching fresh API data.Changes
Modified cache key generation to include
dataSource:Files changed:
src/frontend/src/hooks/useStockData.ts- IncludedataSourcein cache keysrc/frontend/src/hooks/useQuote.ts- IncludedataSourcein cache keysrc/frontend/e2e/data-source-switching.spec.ts- Add E2E tests for data source switchingScreenshot
Chart correctly loading in API mode after fix:
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://storage.googleapis.com/chrome-for-testing-public/143.0.7499.4/linux64/chrome-headless-shell-linux64.zip/usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/FinanceViz/FinanceViz/src/frontend/node_modules/playwright-core/lib/server/registry/oopDownloadBrowserMain.js(http block)https://storage.googleapis.com/chrome-for-testing-public/143.0.7499.4/linux64/chrome-linux64.zip/usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/FinanceViz/FinanceViz/src/frontend/node_modules/playwright-core/lib/server/registry/oopDownloadBrowserMain.js(http block)www.alphavantage.co/home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1200/chrome-headless-shell-linux64/chrome-headless-shell /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1200/chrome-headless-shell-linux64/chrome-headless-shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AvoidUnnecessaryBeforeUnloadCheckSync,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate,AutoDeElevate,RenderD rgo/bin/grep credential.helpenode(dns block)/home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1200/chrome-headless-shell-linux64/chrome-headless-shell /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1200/chrome-headless-shell-linux64/chrome-headless-shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AvoidUnnecessaryBeforeUnloadCheckSync,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate,AutoDeElevate,RenderD rgo/bin/bash(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.