BSON: For React Native please polyfill crypto.getRandomValues

See original GitHub issue

Goals

Regular use.

Expected Results

Regular use.

Actual Results

A warning started appearing after upgrading to Realm 10.4.0.

JSWarning
BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.

    src/conf.js:594:34 
    node_modules/bson/dist/bson.browser.umd.js:2617:18 insecureRandomBytes
    node_modules/bson/dist/bson.browser.umd.js:5182:40 
    node_modules/bson/dist/bson.browser.umd.js:14:9 createCommonjsModule
    node_modules/bson/dist/bson.browser.umd.js:5175:37 
    node_modules/bson/dist/bson.browser.umd.js:2:72 
    node_modules/bson/dist/bson.browser.umd.js:5:2 
    node_modules/metro/src/lib/polyfills/require.js:322:6 loadModuleImplementation
    node_modules/realm/lib/extensions.js:54:35 
    node_modules/realm/lib/index.js:64:24 
    node_modules/metro/src/lib/polyfills/require.js:322:6 loadModuleImplementation
    src/db/index.js:8 

Steps to Reproduce

Just use Realm (offline)

Code Sample

Version of Realm and Tooling

  • Realm JS SDK Version: 10.4.0
  • Node or React Native: React Native
  • Client OS & Version: All
  • Which debugger for React Native: None

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
andrelomba86commented, Jan 22, 2022

I put import 'react-native-get-random-values' before import Realm and the warning stopped.

import 'react-native-get-random-values'
import Realm from 'realm'
2reactions
mednchecommented, Dec 20, 2021

@xtianmpimbaza, nope, still haven’t found a way around it. In my case, it doesn’t prevent Realm writes though.

@kneth, any idea why those warnings are showing?

Read more comments on GitHub >

github_iconTop Results From Across the Web

react native - crypto.getRandomValues() not supported
Works fine on iOS. I solved it with: Uninstall the existing one npm uninstall react-native-webview; Use expo install react-native- ...
Read more >
react-native-get-random-values - npm
A small implementation of crypto.getRandomValues for React Native. This is useful to polyfill for libraries like uuid that depend on it.
Read more >
Can't resolve 'crypto' in node_modules/bson/dist react
I'm using realm-web on my react app to build a simple task reminder app. ... can't resolve 'crypto' in node_modules/bson/dist react.
Read more >
bson - UNPKG
'BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.'.
Read more >
polyfill-crypto.getrandomvalues examples - CodeSandbox
Learn how to use polyfill-crypto.getrandomvalues by viewing and forking polyfill-crypto.getrandomvalues example apps on CodeSandbox.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found