Supabase Chrome Extension: API calls fail after token refresh until manual fetch Problem Description

33 views
Skip to first unread message

Tanzim mahtab

unread,
Aug 30, 2025, 1:20:42 AM (6 days ago) Aug 30
to Chromium Extensions
For a Chrome extension using Supabase, is using direct fetch instead of invoke() the recommended approach for Chrome extensions?

Hello folks, I'm developing a Chrome extension using Supabase and running into a strange issue with authentication after token refresh events.

Setup:

  • MV3 | React | Webpack | Supabase JS Client 
  • Chrome extension with background script
  • Using onAuthStateChange to listen for auth events
  • Making API calls to Supabase Edge Functions

The Issue:

  1. User authenticates ( login with password ) successfully ✅
  2. API calls work fine initially ✅
  3. Token refresh happens automatically (I can see the TOKEN_REFRESHED event) ✅
  4. I get the new session in the auth state change listener ✅
  5. But then: Any subsequent API calls using supabase.functions.invoke() just hang - no response, no error, nothing
  6. Even supabase.auth.getSession() hangs and returns nothing

Here's the strange part: If I make ANY manual fetch request to Supabase after the token refresh, suddenly all supabase.functions.invoke() calls start working again.

For example, 

a) 

// token refreshed                                                                  // await supabase.functions.invoke('my-function', { ... });                                                            // nothing happened 

b ) 

// token refreshed                                                                                                                              // fetch(`${SUPABASE_URL}/functions/v1/my-function`,)                                                        // it works and after that other supabase.functions.invoke('') works perfectly

. My questions are : 

  1. Has anyone experienced this Chrome extension + Supabase token refresh issue?
  2. Is there a proper way to "refresh" the Supabase client's internal state after token refresh?
  3. Why does a manual fetch request fix the invoke() method?
  4. Is using direct fetch instead of invoke() the recommended approach for Chrome extensions?

Any insights would be greatly appreciated! This seems like it might be related to how Supabase manages internal connection state in the Chrome extension environment.

Thanks in advance.

Reply all
Reply to author
Forward
0 new messages