Skip to content

auth.signOut() method fails to return or throw errors, leading to UI hangsΒ #1700

@NotJoeMartinez

Description

@NotJoeMartinez

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

The supabase.auth.signOut() method fails to return or throw errors when signing out a valid user session. It still signs out the user but this only is reflected when the user manually reloads the page. This was addressed in supabase/auth-js#345 but the suggested method useSupabaseAuthClient(); appears to be deprecated.

To Reproduce

The following vue component is rendered on /signout the user is directed to this page when they click a singout button in the nav bar. No error is thrown and nothing is logged when this page renders. No other links in the nav bar that use router.push work either so I believe this is cause by await supabase.auth.signOut(); not returning. I've resorted to just having a manual link back to the home page of my application.

In my project I'm using pinia to handle the supabase client but I'm exuding that from this example for simplicity, the behavior is identical to my example.

SignOutPageView.vue:

<script setup>
import { onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { createClient } from "@supabase/supabase-js";

const router = useRouter();
const supabase = createClient(supabaseUrl, supabaseKey); // replace with valid credentials 

const signOut = async () => {
  try {
    const { error } = await supabase.auth.signOut();
    if (error) throw error;
    console.log('Signed out successfully');
  } catch (error) {
    console.error('Error signing out:', error.message);
  } finally {
    router.push('/');
  }
};

onMounted(() => {
  signOut();
});
</script>

<template>
    <h1>Signing you out...</h1>
    <p>
        If you are still not redirected after 5 seconds click this 
        link to return to home page <a href="/">https://example.com</a>
    </p>
</template>

Expected behavior

supabase.auth.signOut(); should return an error or complete its process allowing the rest of the code to continue.

System information

  • OS: [macOS]
  • Browser [chrome, firefox, safari]
  • Version of supabase-js: [2.64.2]

Additional context

Recent discord thread about this: https://discord.com/channels/839993398554656828/1260740210178654249

Metadata

Metadata

Assignees

No one assigned

    Labels

    auth-jsRelated to the auth-js library.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions