supabase.auth.getUser() returns error on vue-router route guard

I am attempting to build a Vue application that uses Supabase authentication. Inside one of the route guards in the router file, I implemented supabase.auth.getUser() in order to retrieve the user login status for a conditional that prevents next() from executing before the user is authenticated:

// Route guard for auth routes
router.beforeEach((to, from, next) => {
  // const user = supabase.auth.user();
  const user = supabase.auth.getUser();

  if (to.matched.some((res) => res.meta.auth)) {
    if (user) {
      next();
      return;
    }
    next({ name: "Login" });
    return;
  }
  next();
});

However, when I implement supabase.auth.getUser() inside the router guard, I get the following error in the console before logging in: “invalid claim: missing sub claim”. After logging in, the error goes away. If I remove the supabase.auth.getUser conditional from the route guard, the error also goes away. What is this error and how can I resolve it?