onAuthStateChange not triggered on account deletion

I have created a function to allow users to delete their account.
create or replace function delete_user()
  returns void
LANGUAGE SQL SECURITY DEFINER as $$
   delete from auth.users where id = auth.uid();
$$;

This works just fine to delete the account. I now want to perform an action in my code when that happens. I want this action to trigger within the onAuthStateChange. The problem is the 'USER_DELETE' event never gets triggered. I am running the function via rpc, so not sure if that is causing the problem.
const { data } = SUPABASE.auth.onAuthStateChange((_event, session) => {
    switch (_event) {
    case 'SIGNED_IN':
        setSession(session as Session);
        profileSetter(session as Session);
                navigate('/dashboard');
        break;
    case 'SIGNED_OUT':
        setSession(null);
        setProfile(null);
                navigate('/');
        break;
    case 'TOKEN_REFRESHED':
        setSession(session as Session);
        break;
    case 'USER_UPDATED':
        setSession(session as Session);
        profileSetter(session as Session);
        break;
    case 'USER_DELETED':
                console.log('hit'); // never runs
        setSession(null);
        setProfile(null);
        break;
    }
});

Let me know if I can provide any other information!
Was this page helpful?