Skip to content

Fix: TypeError in GoogleButton - OAuth client not initialised on click #6554

@talissoncosta

Description

@talissoncosta

Bug Description

Users encounter a TypeError when attempting to sign in with Google on slow connections. The OAuth client is not ready when the user clicks the button.

Error:

TypeError: Cannot read properties of undefined (reading 'requestAccessToken')

Sentry Issue: https://flagsmith.sentry.io/issues/FLAGSMITH-FRONTEND-462

Priority: Low

This is not critical because:

  • Only affects users on slow network connections
  • Does not break the page or block other functionality
  • Users can retry and the button will work once the SDK loads
  • Email/password and other login methods remain functional

Impact

  • 42 users affected
  • 115 events since first seen (2025-04-28)
  • Affects Google authentication on slow connections only

Steps to Reproduce

  1. Open Chrome DevTools → Network tab
  2. Set throttling to Slow 3G
  3. Navigate to https://app.flagsmith.com/
  4. Click the Google button before the page fully loads
  5. Error occurs in console

Root Cause

In GoogleButton.tsx:27, the login() function is called without checking if the Google OAuth client is ready:

onClick={() => login()}

On slow connections, the Google SDK hasn't initialised clientRef.current yet.

Suggested Fix

Disable the button until the OAuth client is ready:

const { login, ready } = useGoogleLogin({ ... })

<Button
  disabled={!ready}
  onClick={() => login()}
>
  Google
</Button>

Files to Modify

  • frontend/web/components/GoogleButton.tsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfront-endIssue related to the React Front End Dashboard

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions