@@ -117,11 +117,13 @@ export default class SupabaseClient<
117117    } 
118118
119119    this . fetch  =  fetchWithAuth ( supabaseKey ,  this . _getAccessToken . bind ( this ) ,  settings . global . fetch ) 
120+ 
120121    this . realtime  =  this . _initRealtimeClient ( { 
121122      headers : this . headers , 
122123      accessToken : this . _getAccessToken . bind ( this ) , 
123124      ...settings . realtime , 
124125    } ) 
126+ 
125127    this . rest  =  new  PostgrestClient ( `${ _supabaseUrl }  ,  { 
126128      headers : this . headers , 
127129      schema : settings . db . schema , 
@@ -319,14 +321,13 @@ export default class SupabaseClient<
319321    } ) 
320322  } 
321323
322-   private  _listenForAuthEvents ( )  { 
323-     let   data   =  this . auth . onAuthStateChange ( ( event ,  session )  =>  { 
324+   private  async   _listenForAuthEvents ( )  { 
325+     return   await  this . auth . onAuthStateChange ( ( event ,  session )  =>  { 
324326      this . _handleTokenChanged ( event ,  'CLIENT' ,  session ?. access_token ) 
325327    } ) 
326-     return  data 
327328  } 
328329
329-   private  _handleTokenChanged ( 
330+   private  async   _handleTokenChanged ( 
330331    event : AuthChangeEvent , 
331332    source : 'CLIENT'  |  'STORAGE' , 
332333    token ?: string 
@@ -337,7 +338,7 @@ export default class SupabaseClient<
337338    )  { 
338339      this . changedAccessToken  =  token 
339340    }  else  if  ( event  ===  'SIGNED_OUT' )  { 
340-       this . realtime . setAuth ( ) 
341+       await   this . realtime . setAuth ( ) 
341342      if  ( source  ==  'STORAGE' )  this . auth . signOut ( ) 
342343      this . changedAccessToken  =  undefined 
343344    } 
0 commit comments