Skip to content

crypto.randomUUID does not generate proper V4 formatted UUIDs #269

@widavies

Description

@widavies

According to MDN, crypto.randomUUID should generate a valid UUID version 4:

https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID#:~:text=A%20string%20containing%20a%20randomly%20generated%2C%2036%20character%20long%20v4%20UUID.

According to the spec, UUID V4s have the format:

xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx

where M is the UUID version field (4) and N encodes the variant 8, 9, A, or B.

I'm seeing my Convex functions generate 4 properly, but not the variant:

[LOG] 'value' '42e356e7-3691-429d-f59f-030d808bc286'
[LOG] 'value' '1f03317b-b485-41e0-62bf-14a3716022ca'
[LOG] 'value' '82a39a93-7425-4a59-f1ae-a43b0b2131c9'

I know that Convex runs on a custom runtime, so not sure if something different is going on here. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions