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

v1.9.0 throws "unordered_map::at: key not found" error #49

Open
landabaso opened this issue Sep 15, 2023 · 4 comments
Open

v1.9.0 throws "unordered_map::at: key not found" error #49

landabaso opened this issue Sep 15, 2023 · 4 comments

Comments

@landabaso
Copy link

landabaso commented Sep 15, 2023

When executing version v1.9.0 of the library, an exception is thrown at this line: global.expo.modules.ExpoCrypto.getRandomValues(array).

Here's the full error log:

ERROR  Error: Exception in HostFunction: unordered_map::at: key not found, js engine: hermes

I am utilizing this package alongside randombytes.

The array variable, which originates from randombytes, is initialized at this location.

Additional context that might be helpful:

  • I'm running the app on an iOS simulator using the command: npx expo start -c.

  • Buffer support was added with: npm install buffer.

    And it's being shimmed in the following manner:

    import { Buffer } from "buffer";
    global.Buffer = Buffer;

For further clarity, I've tracked the function call in version v1.8.0, and it ultimately leads to global.ExpoModules.ExpoRandom.getRandomBase64String(byteLength);, which runs without any hitches.

For now, I've reverted to using v1.8.0. Appreciate the efforts behind this library, and I hope this information aids in resolving the issue.

@LinusU
Copy link
Owner

LinusU commented Sep 15, 2023

Thank you for taking the time to investigate and report!

Are you able to reproduce this if you just run the following lines, without this library at all?

const array = new Uint8Array(10)
global.expo.modules.ExpoCrypto.getRandomValues(array)

and do you get the same error if you import getRandomValues from expo-crypto and call that directly?

Also, which version of Expo are you using? and does the same error happen even if you remove your global Buffer polyfill?

@Mastaleru
Copy link

Example to reproduce this issue:
repo: https://github.com/Mastaleru/rn-learn/tree/625f9d2791442e622f85c4d46cb1e9317c2bbfee/first_project
package.json

  "dependencies": {
    "expo": "~49.0.13",
    "expo-status-bar": "~1.6.0",
    "react": "18.2.0",
    "react-native": "0.72.5",
    "react-native-get-random-values": "^1.9.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },

More context:

  • It works on Android, fails on iOS.
  • I'm using in conjunction with a browserified lib that does not have support for crypto.getRandomValues

@CarlosVilasAlvarez
Copy link

Same behaviour, after v1.9.0 it crashes using expo v49 with realm-js (which needs this polyfill to run safely).

@gvanderclay
Copy link

This is still occurring on v1.11.0 with expo 51 and realm 12.

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

No branches or pull requests

5 participants