onSuccess bug?

onSuccess requires 1s setTimeout before redirecting, otherwise the session is null. the documentation doesn't mention this, I was expecting that onSuccess means the session was already set, is this a bug?

await authClient.signIn.email(
        {
          email: value.email,
          password: value.password,
        },
        {
          onSuccess: () => {
            const SIGN_IN_SUCCESS_REDIRECT_DELAY_MS = 1000;
            setTimeout(() => {
              router.push("/dashboard");
              toast.success("Sign in successful");
            }, SIGN_IN_SUCCESS_REDIRECT_DELAY_MS);

 const { data: session, isPending } = authClient.useSession();

  useEffect(() => {
    if (!(session || isPending)) {
      router.push("/login");
    }
  }, [session, isPending]);
Was this page helpful?