perry-mitchell / ulidx

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

Safari exception "TypeError: crypto.randomUUID is not a function" #36

Closed knackstedt closed 12 months ago

knackstedt commented 12 months ago

Can we add a troubleshooting note that this error will occur when using ulid() on an site served via http. When using https, this error will not be thrown as the browser will support randomUUID.

perry-mitchell commented 12 months ago

I wonder if there's some confusion here as ulidx doesn't make use of any randomUUID method. Ulidx generates random bytes. Could this be from some other library?

That being said I understand that some methods are not available under insecure environments and I would accept documentation PRs that address this.

knackstedt commented 12 months ago

It appears I am indeed confused. I'm going to double check what's going on for me, but I'm seeing that error show up specifically when I call ulid() and it returns null. I wonder if I have a bad polyfill

knackstedt commented 12 months ago

By the by, much love for making this library. I really appreciate unique random IDs that are sequenced -- so much easier to deal with for me :smile:

knackstedt commented 12 months ago

Turns out my app does have something terrible going on in a polyfill that someone wrote, so this was a red herring unfortunately. Thanks for the attempted assist @perry-mitchell ! Greatly appreciated mate :)

perry-mitchell commented 12 months ago

By the by, much love for making this library.

Thanks for saying so! Though remember that I just forked it, the credit lies with the original author. I do enjoy maintaining it though!

Turns out my app does have something terrible going on in a polyfill that someone wrote, so this was a red herring unfortunately.

Ah, well good you found it! Hope the solution is easy enough.

Hope to see you around mate!