Skip to content

Fix analytics tab not rendering on first click#22

Merged
guitavano merged 1 commit into
mainfrom
fix/analytics-tab-race-condition
Jun 25, 2026
Merged

Fix analytics tab not rendering on first click#22
guitavano merged 1 commit into
mainfrom
fix/analytics-tab-race-condition

Conversation

@guitavano

@guitavano guitavano commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix race condition where the <stonks-dashboard> custom element was created before the external scripts defining its class had loaded
  • loadScript now returns a Promise that resolves on onload
  • AnalyticsTab waits for both scripts to load via Promise.all before rendering the custom element

Test plan

  • Open monitor page and click the Analytics tab — should render on the first click
  • Verify Performance tab still works normally
  • Test with slow network (throttling) to confirm no blank state

🤖 Generated with Claude Code


Summary by cubic

Fixes a race condition that left the Analytics tab blank on first click. The tab now waits for the dashboard scripts to load before rendering the web component, so it shows up reliably even on slow networks.

  • Bug Fixes
    • loadScript now returns a Promise (resolves on onload, rejects on onerror).
    • AnalyticsTab uses Promise.all to load stonks-dashboard.js and stonks-insights.js, sets scriptsReady, and renders only after both are loaded.

Written for commit 6dd9e18. Summary will update on new commits.

Review in cubic

The stonks-dashboard custom element was being created before the external
scripts defining its class had loaded. The Svelte web component didn't
upgrade properly, leaving the tab blank until a second click (when scripts
were cached). Now loadScript returns a Promise and AnalyticsTab waits for
both scripts to load before rendering the custom element.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
admin-mcp 6dd9e18 Commit Preview URL

Branch Preview URL
Jun 25 2026, 03:50 PM

@guitavano guitavano merged commit 119f450 into main Jun 25, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant