Is the createUniqueId-helper safe to use?

We are currently using the createUniqueId-helper on the client only and today one of our data entries was overwritten. We are relatively sure, that this was because its ID was generated a second time when we created a new data entry. Can id clashes happen? Ids are rather short, so I imagine that this is definitely a possibility. Would it be better to switch to something like nanoid here, which can be configured to use a longer id?
2 Replies
REEEEE
REEEEE2y ago
I ran into an issue with it recently when implementing saving and loading data in my project. Since createUniqueId basically is based on a counter that increases on each use, if you load data that has ids generated by createUniqueId they won't count towards that counter and thus cause clashes. I would switch to nanoid
oneiro
oneiroOP2y ago
thats what I thought. We should probably add this somewhere to the docs, as this can lead to data corruption when misused.
Want results from more Discord servers?
Add your server