fix(deps): make react-native-get-random-values optional - #1310
Merged
Conversation
crypto.getRandomValues can already be polyfilled by other packages (e.g. react-native-quick-crypto), so requiring react-native-get-random-values unconditionally forces an unnecessary install on apps that already have a polyfill in place. Marks it optional in both core and sovran's peerDependenciesMeta, and loads it defensively at module scope the same way this codebase already handles the optional async-storage peer dependency (packages/sovran/src/persistor/async-storage-persistor.ts). getUUID() now surfaces a clear error only if crypto.getRandomValues genuinely isn't available. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to #1298 (by @SYoder1), same goal:
react-native-get-random-valuesis a hard peer dependency used purely to install acrypto.getRandomValuespolyfill, but some apps already polyfill it themselves (e.g. viareact-native-quick-crypto) and shouldn't be forced to install a redundant package.This takes a different implementation approach than #1298:
react-native-get-random-valuesoptional inpeerDependenciesMetafor bothcoreandsovran(same as fix(deps): switch react-native-get-random-values to optional #1298).packages/core/src/uuid.tsusing the sametry { require(...) } catch {}idiom this codebase already uses for the optional@react-native-async-storage/async-storagepeer dependency (packages/sovran/src/persistor/async-storage-persistor.ts), rather than introducing a new localrequiretype declaration.getUUID()now throws a clear, actionable error only ifcrypto.getRandomValuesgenuinely isn't available (neither via the polyfill nor any other source) — apps with a working polyfill see no behavior change.Not a breaking change: apps that already have
react-native-get-random-valuesinstalled keep working identically (the module still getsrequired for its side effect); this only removes the forced install for apps using a different polyfill.Verified locally:
yarn lint,yarn format:check(prettier only —shfmtunavailable in my env, but no.shfiles are touched),yarn build,yarn typecheck, andyarn test(70/70 suites, 492 passed) all pass with no new warnings introduced.🤖 Generated with Claude Code