Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_crypto.randomUUID is not a function #8106

Closed
law-rence opened this issue Aug 8, 2022 · 4 comments · Fixed by #8109
Closed

_crypto.randomUUID is not a function #8106

law-rence opened this issue Aug 8, 2022 · 4 comments · Fixed by #8109

Comments

@law-rence
Copy link
Contributor

File: packages/store/addon/-private/identifier-cache.ts:37

Tested in Chrome Android Version 69 -> the functionality is available at Version 92
(https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID)

The issue occurs on using "createRecord". The fast boot mode is false, so it uses window.crypto that results in an empty object. The consequence, the function "randomUUID" is not defined.

Is there any polyfill, downward compatibility ?

Thank you a lot for your work.

@samcic
Copy link

samcic commented Aug 8, 2022

Safari < 15.4 also doesn't have this method available so it's also quite relevant for iOS users (particularly those using the slightly older iPhone 5, 6 and 6 Plus models which are stuck at iOS 12.5.5 as the final OS).

@runspired
Copy link
Contributor

This is mostly a duplicate of #8097 so I'm going to close it in favor of that. We'll be adding the ability to include a polyfill when needed to address that ticket, especially as this isn't one of the API's that babel will typically polyfill for you based on target. The function is valid on all modern browser targets at this point, but ensuring there can be some lag seems like a good idea.

@runspired
Copy link
Contributor

Oh I'd also add you actually can provide your own lid function and in doing so bypass the uuid generation by using setIdentifierGenerationMethod: https://api.emberjs.com/ember-data/release/modules/@ember-data%2Fstore. We should make it polyfillable but in the mean time feel free to fix by override.

@gorner
Copy link

gorner commented Jul 16, 2024

For reference as to how to setup the above-referenced polyfill for anyone coming across this, since I can't really think of a better place to document:

Unfortunately this was not well-documented when my app recently upgraded to Ember Data 4.12. We came across the 5.3.4 instructions first and assumed it also applied to 4.12, then after finding the right config, we didn't know about needing to add the dependency until coming across a message to that effect in Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants