allenA
Convex Community3y ago
16 replies
allen

Auth not working for some users

I have the same codebase running from two devices for two users and seeing two different sets of behavior and unsure how to resolve.

My client does the following:

      const createUser = useMutation('users/mutations/createUser');
      ...
      await convexClient.setAuth(async () => getToken({ template: 'convex' }));
      await createUser(); // 


For one user, everything works as expected. For another, my createUser mutation throws because the request isnt authorized (auth.getUserIdentity() returns null).

I have verified that a JWT is returned from getToken.

I set a timeout prior to calling the mutation of 1000ms to see if there was a race condition, but that produced the same results.

I am unsure how to further debug this or inspect why
setAuth
doesnt appear to be functioning in this case.
Was this page helpful?