perry-mitchell / ulidx

ULID generator for NodeJS and the browser
MIT License
281 stars 17 forks source link

Monotonically increasing guarantee in the same millisecond #14

Open serhattanrikut opened 1 year ago

serhattanrikut commented 1 year ago

Hello @perry-mitchell

Do you plan to fix the issue mentioned in ulid/javascript#74 -->

If multiple UUIDs are generated in the same millisecond, the random bits are not guaranteed to be monotonically increasing. So given const [a, b, c] = [ulid(), ulid(), ulid()] c and b could sort lower than a

This implementation already has an algo for incrementing the base32 of the ulid. It should just change to increment the most significant bits instead of the least significant bits of the random portion.

Thanks.

perry-mitchell commented 1 year ago

Hi @serhattanrikut - I checked the linked issue (and the issues/PRs linked therein) and yes, I would accept such a fix on this fork.

Not sure if I have the time right now to get to it myself, but I would certainly accept a PR for it.

paynecodes commented 6 months ago

@perry-mitchell Does the existing Monotonic ULID factory support this now? Should this issue be closed?

perry-mitchell commented 6 months ago

No, I don't think anything was merged for this. I'm not confident I can test this exact eventuality correctly so it'd be better if someone with more experience on this would contribute a patch.