rse / pure-uuid

Pure JavaScript Based Universally Unique Identifiers (UUID)
https://www.npmjs.com/package/pure-uuid
66 stars 16 forks source link

Malformed UUIDs v4 #17

Open bennycode opened 4 years ago

bennycode commented 4 years ago

I have been using new UUID(4).format() and noticed that it generates some invalid / malformed UUIDs.

A proper UUID v4 looks like this:

But I somehow received the following UUIDs:

Is it possible that UUID(4).format() generates UUIDs with too many dashes (with 1 extra char per extra dash)? Can this library be affected by a sign problem?

rse commented 4 years ago

I cannot reproduce your problem:

$ cat test.js 
const UUID = require("./")
for (let i = 0; i < 100000; i++)
     console.log(new UUID(4).format())
$ node test.js | egrep -v '^.{36}$' 

Even with 100K generated UUIDs it was always 36 characters in total...

Yserz commented 4 years ago

We replaced the library without other changes and the issue went away.

bennycode commented 4 years ago

@rse we experienced the described problem only with some users but reliably. Is it possible that your algorithm uses system specific values for its computation?