Errors Ergonomics
Hello, two questions regarding Errors, Auth and Pagination
Context: I use firebase authentication that I inject within my convex queries with the auth hook. So, at the end of the day, I get server-side the auth id of my users thanks to
ctx.auth.getUserIdentity()
. I used the approach to throw a ConvexError
on the server if some query requests are not authenticated according to this doc.
Problem:
1) It seems like the queries are still running when the JWT expires. So the queries throw an error because getUserIdentity
returns undefined.
I am not very used to auth, but wouldn't it be better that the convex auth hook in the client fetches a new JWT when the JWT is expired and goes to loading mode meanwhile?
2) When I hit an auth error, although that's not optimal, I decided to return "empty" values. Ever undefined for normal queries or an empty pagination response. I did it like below for pagination. However that still makes the UI crashes and convex servers are returning the following when my JWT expires: Uncaught Error: InvalidCursor: Tried to run a query starting from a cursor, but it looks like this cursor is from a different query. at async handler (../convex/usersVisited.ts:107:17)
. Is there a convenient value that is exported from convex to model a generic empty pagination result?
Thanks in advance!0 Replies