#Store user mutation in production
9 messages · Page 1 of 1 (latest)
any more details on the failure?
this is the function. the user is already stored in the db after sign up through webhook call. I'm trying to update the user table and add a firebase uuid
export const storeUser = mutation({
args: {
firebaseUserId: v.string(),
},
handler: async (ctx, args) => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) {
throw new Error('Unauthenticated');
}
// check if user is already stored
const user = await ctx.db
.query('users')
.withIndex('by_token_identifier', (q) =>
q.eq('tokenIdentifier', identity.tokenIdentifier)
)
.unique();
if (user === null) {
throw new Error('No user found');
}
const userId = await ctx.db.patch(user._id, {
email: identity.email,
firebaseUserId: args.firebaseUserId,
});
return userId;
},
});
Uncaught Error: No user found is what am getting in at prod. During local development it works just fine
How are you creating users? Have you checked your Convex dashboard to see whether the user document is in the table?
Yes. The user exists in the dashboard. I invoked a webhook intergrated with clerk
The functions fails to find the stored user
In your production dashboard? You can switch between "dev" and "prod" up top.