Lurker News
I know what you're thinking... and I still can't believe it, but...

This morning, our database flagged a duplicate UUID (v4). I checked, thinking it may have been a double-insert bug or something, but no.
The original UUID was from a record added in 2025 (about a year ago), and today the system inserted a new document with a fresh UUIDv4 and it came up with the exact same one:
b6133fd6-70fe-4fe3-bed6-8ca8fc9386cd
We're using this: https://www.npmjs.com/package/uuid
I thought this is technically impossible, and it will never happen, and since we're not modifying the UUIDs in any way, I really wonder how that.... is possible!? We're literally only calling:
import { v4 as uuidv4 } from "uuid";
const document_id = uuidv4();
... and then insert into the database, that's it.
Additionally, the database only has about 15.000 records, and now one collision. Statistically... impossible.
Has that ever happened to anyone?! What in the...

Comments (347) 79 threads

Show all comments

Showing thread 8 of 79

D2OQZG8l5BI1S063 replies#
That makes sense. I'm not sure why anybody would generate UUIDs in browsers though, it seems to defeat the purpose.
danpalmer#
Tell that to Segment. Hopefully they've fixed that, but they didn't seem to think it was a problem years ago (spoiler: it was a big problem).
perlgeek#
When you do CQRS, you basically have to generate some form of unique identifier in the client. Why not a UUID in the browser?
dylanhouli#
> I'm not sure why anybody would generate UUIDs in browsers though, it seems to defeat the purpose.

How about for offline-first apps?