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

Error: crypto.getRandomValues() When i try to create anything #1973

Closed
YousefAlsbaihi opened this issue Jul 14, 2023 · 4 comments
Closed

Error: crypto.getRandomValues() When i try to create anything #1973

YousefAlsbaihi opened this issue Jul 14, 2023 · 4 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@YousefAlsbaihi
Copy link

Issue Description

When i try to create anything Class, User, any kind of data i get the error

[Error: crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported]

Steps to reproduce

const Parse = require('parse/react-native.js');
import AsyncStorage from '@react-native-async-storage/async-storage';
Parse.setAsyncStorage(AsyncStorage);
    Parse.initialize('XXX', 'XXX');
    Parse.serverURL = 'https://parseapi.back4app.com/'
    try {
        const newPerson = new Parse.Object('Person');
        newPerson.set('name', 'John');
        newPerson.set('email', 'john@back4app.com');
        await newPerson.save();
    } catch (error) {
        console.log('Error saving new person: ', error);
    }

Environment

Server

  • Parse Server version: 4.5.0
  • Operating system: MacOs
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): back4app

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 3.6

Client

  • Parse JS SDK version: 4.1.0 React Native
@parse-github-assistant
Copy link

Thanks for opening this issue!

@YousefAlsbaihi
Copy link
Author

after hours of searching i actually solved it by

npm i -s import react-native-get-random-values

and then import it before initialize Parse

import 'react-native-get-random-values';
const Parse = require('parse/react-native.js');
import AsyncStorage from '@react-native-async-storage/async-storage'
....

i'm sure this is uuid library issue

@dplewis
Copy link
Member

dplewis commented Aug 31, 2023

I'm glad you were able to resolve this issue. The latest version of node has crypto globally available now. uuidjs/uuid#708

@dplewis dplewis closed this as completed Aug 31, 2023
@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Sep 1, 2023
@andre-sonect
Copy link

andre-sonect commented Sep 6, 2023

Unfortunately I still suffer from this using latest node LTS with parse server and dashboard. Tried the above solution on react-native just to find another issue Native module not found.
Anyone looking into this you also need to npx react-native link. After that all good.

@mtrezza mtrezza reopened this Sep 7, 2023
@mtrezza mtrezza closed this as completed Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

4 participants