Skip to content

Fix race condition: defer license fetch until Firebase auth is ready#111

Merged
Alessandro100 merged 2 commits intomainfrom
copilot/fix-license-detail-error
Apr 14, 2026
Merged

Fix race condition: defer license fetch until Firebase auth is ready#111
Alessandro100 merged 2 commits intomainfrom
copilot/fix-license-detail-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

On a cold browser load (incognito, direct URL), clicking "See License Details" before Firebase's onIdTokenChanged has fired causes getUserAccessToken() to throw "Cannot retrieve access token"currentUser is still null at that point.

Changes

  • LicenseDialog.tsx
    • Consume isAuthReady from the existing useAuthSession() context
    • Gate the loadingLicense dispatch on isAuthReady, so the fetch is deferred until Firebase has a resolved user (anonymous or authenticated)
    • Show CircularProgress while waiting for auth to initialize, preventing a blank dialog
// Before
useEffect(() => {
  if (open && licenseId != undefined) {
    dispatch(loadingLicense({ licenseId }));
  }
}, [open, licenseId, dispatch]);

// After
const { isAuthReady } = useAuthSession();

useEffect(() => {
  if (open && licenseId != undefined && isAuthReady) {
    dispatch(loadingLicense({ licenseId }));
  }
}, [open, licenseId, dispatch, isAuthReady]);

When isAuthReady flips to true the effect re-runs automatically, so there is no change to the happy path for already-authenticated sessions.

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:

  • download.cypress.io
    • Triggering command: /opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node index.js --exec install (dns block)
    • Triggering command: /opt/hostedtoolcache/node/24.14.1/x64/bin/node /opt/hostedtoolcache/node/24.14.1/x64/bin/node dist/index.js --exec install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mobilitydatabase-web Ready Ready Preview, Comment Apr 14, 2026 0:30am

Request Review

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix license detail retrieval error on new browser Fix race condition: defer license fetch until Firebase auth is ready Apr 14, 2026
Copilot AI requested a review from Alessandro100 April 14, 2026 12:31
@Alessandro100 Alessandro100 marked this pull request as ready for review April 14, 2026 14:01
Copy link
Copy Markdown
Contributor

@Alessandro100 Alessandro100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested locally, works well

Copy link
Copy Markdown
Contributor

@qcdyx qcdyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link
Copy Markdown

*Lighthouse ran on https://mobilitydatabase-573lwc4un-mobility-data.vercel.app/ * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟢 99 🟢 94 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-573lwc4un-mobility-data.vercel.app/feeds * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 85 🟠 87 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-573lwc4un-mobility-data.vercel.app/feeds/gtfs/mdb-2126 * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 81 🟢 94 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-573lwc4un-mobility-data.vercel.app/feeds/gtfs_rt/mdb-2585 * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟢 98 🟠 84 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-573lwc4un-mobility-data.vercel.app/feeds/gbfs/gbfs-flamingo_porirua * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 86 🟢 94 🟢 96 🟢 100

@Alessandro100 Alessandro100 merged commit 60bca82 into main Apr 14, 2026
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.

New Browser Feed Detail error getting license

5 participants