How to fix Uncaught Error: Not found
I have this getTeams query:
I receive this error when no teams can be found where the user is also a member.
How can I solve this?
5 Replies
You're writing the current user to the database, either via
useEffect
or a webhook. You need to block the client from subscribing to the query (or let the query return while the user isn't in the DB yet). The former is described here:
useEffect:
https://docs.convex.dev/auth/database-auth#calling-the-store-user-mutation-from-react
webhooks:
https://docs.convex.dev/auth/database-auth#waiting-for-current-user-to-be-storedStoring Users in the Convex Database | Convex Developer Hub
You might want to store user information directly in your Convex database, for
The latter (returning while the user hasn't been returned yet) is shown here: https://github.com/Nutlope/notesGPT/blob/main/convex/notes.ts#L45
client can do
GitHub
notesGPT/convex/notes.ts at main · Nutlope/notesGPT
Record voice notes & transcribe, summarize, and get tasks - Nutlope/notesGPT
Thank you for going through this @Michal Srb . I'm already storing the user in the database, but not explicitly how the documentation describes it. I have a create user mutation that I use if the getUser doesn't return any one.
This is my application layout where it goes wrong with the teams getTeams query:
Not sure what I'm doing wrong with getTeams, as of queries works just fine.
You are not blocking this query from executing before the client is authenticated or the user is created.
I ended up doing it in the client. I added the convex-helpers and listened to isPending. Thanks for the help 🙂