This is actually a pretty interesting question, with a number of levels to it.
First, it's worth noting that uuid.js supports two different forms of id. uuid.v4()
creates IDs using random numbers, while uuid.v1()
creates IDs based on timestamps. The "version" of the id is actually encoded in the id itself, which guarantees that in theory no v4 id will ever collide with a v1 id. That's part of RFC4122, the UUID specification.
It's also worth noting that for v1 ids, each id source is supposed to have a unique "node id", also encoded in the id, that guarantees the uniqueness of id sequence created by that source. For id sources that have access to a guaranteed-unique value (e.g. a device's MAC address) this works well. However uuid.js doesn't have access to such a value and, thus, generates a random value for it's node id. This introduces the risk of it generating a node id that matches the one used by your server. The node id is 48-bit value, meaning the chance of a node id collision are 281,474,976,710,656:1. So, theres a chance, but it's pretty damn low.
... but none of that matters!
It turns out that even though NewSequentialID()
produces IDs that are superficially similar to v1 IDs, Microsoft for whatever reasons decided to swap the various fields within the ID around, breaking RFC4122 compatability. What this means is that, depending on the sequence number, the IDs may or may not look like valid v1 ids, or valid v4 ids, or simply invalid UUIDs. I.e. using NewSequentialID()
throws a wrench into the works if you want to talk about the possibility of uuid collision.
I'm not sure there's a simple way to quantify the risk of collision given this last issue. At the end of the day, UUIDs are 128-bit values, meaning there's a HUGE numberspace to draw from. For all but the most demanding of requirements you're probably okay. But there will be an increased risk of collision compared to what you'd have if you used an RFC-compliant UUID source.
[FWIW, your uuid.js comes from the node-uuid project (*cough* said the author).]