Whenever I call authClient.signOut() from a rendered component that uses a query which in turn calls authComponent.getAuthUser(ctx), I am getting an Uncaught ConvexError: Unauthenticated at getAuthUser [as getAuthUser].
Below is a simplified example of my setup:
// component.ts
export default function Component() {
const data = useQuery(api.data.get);
if (!data) {
return <div>Loading...</div>
}
return (
<>
{data}
</>
)
}
// data.ts
export const get = query({ // is triggered again on authClient.signOut(), not sure why
handler: async (ctx) => {
const identity = await authComponent.getAuthUser(ctx); // triggered again on authClient.signOut(), throws error because unauthenticated
// get and return data
},
});
Component is wrapped in an <Authenticated> tag. The error is only thrown when signing out, otherwise it works just fine.
"next": "16.0.10"
"better-auth": "1.4.7"
"@convex-dev/better-auth": "^0.10.6"