Cashed
Cashed2w ago

Anyone have a good solution for

Anyone have a good solution for optimistic updates and having temporary IDs that conflict with the actual convex ID? For example, I am adding messages to my chat app optimistically and for each message I have a query that takes in that ID to fetch the reactions of the message. Obviously when I optimistically add a message with a fake uuid convex complains since it's querying something that doesn't exist (yet)
8/13/2025, 8:45:03 PM [CONVEX Q(reactions:listByMessage)] ArgumentValidationError: Value does not match validator.
Path: .messageId
Value: "73b9f060-f13e-42a0-a75e-f1ea3a2aa6bb"
Validator: v.id("messages")
8/13/2025, 8:45:03 PM [CONVEX Q(reactions:listByMessage)] ArgumentValidationError: Value does not match validator.
Path: .messageId
Value: "73b9f060-f13e-42a0-a75e-f1ea3a2aa6bb"
Validator: v.id("messages")
Is this something to worry about or fix?
3 Replies
Cashed
CashedOP2w ago
Maybe this is what I'm looking for? https://github.com/shuding/legid
GitHub
GitHub - shuding/legid: A library for generating safe, legit and ra...
A library for generating safe, legit and random URL-compat IDs. - shuding/legid
Cashed
CashedOP2w ago
I.e. generate the ID on the client and use in my optimistic update, use that as my actual message ID on the server when inserting the message?
Gi
Gi2w ago
You should probably skip the query for items that don't have an actual convex id

Did you find this page helpful?