question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React-native: uuid not working when debugger is disabled

See original GitHub issue

Describe the bug

In my react-native application, I am using:

import { uuidv4 } from 'uuid';
uuidv4()

The uuid get generated successfully when the app is running on debug mode (The debugger is enabled). However, if you turn off the debugger, it does not work, as soon as the app reaches uuidv4() line of code, it stops there without any error in the console.

How to reproduce

  1. npx react-native init AwesomeProject
  2. yarn install uuid
import { uuidv4 } from 'uuid';
uuidv4()
  1. Test the app, should not work
  2. ctrl + d to open the developer menu, select Debug
  3. It will start working as normal

Expected behavior

The app should work as normal in both debug mode being enabled and disabled.

Runtime

System:
    OS: macOS 10.15.7
    CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
    Memory: 392.40 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node
    Yarn: 1.22.4 - ~/Documents/youpendo-app-bareworkflow/node_modules/.bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.1, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.6 AI-192.7142.36.36.6392135
    Xcode: 12.1/12A7403 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_232 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: ^4.8.0 => 4.13.0
    react: 16.13.1 => 16.13.1
    react-native: 0.63.3 => 0.63.3

Additional information

[Any other information or comments that you think will help]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ctavancommented, Nov 9, 2020

Oops. I stopped reading the example code after import because I saw that the polyfill was missing… But you are obviously right, @broofa, in addition to the missing polyfill it must also read:

import 'react-native-get-random-values';
import { v4 as uuidv4 } from 'uuid';

Just like in the documentation: https://github.com/uuidjs/uuid#react-native--expo

1reaction
ctavancommented, Nov 9, 2020

Did you follow the documentation and install react-native-get-random-values?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugger Unavailable : Debugging is not currently supported ...
Is there any workaround while waiting for an official support to debug javascript in the new React Native architecture? react-native.
Read more >
React native app only works with debug enabled? - Reddit
Seems to be happening on both iOS simulator and iOS device. When debug is not enabled, it loads up, stays at 100% with...
Read more >
JavaScript - Docs - PostHog
This will enable debugging, easily allowing you to see all data that is being sent to PostHog. Development. For instructions on how to...
Read more >
How to use the react-native-firebase.storage function in ... - Snyk
UUIDGenerator.getRandomUUID((uuid) => { consolelog(`DEBUG firebase/uploadReport(), uuid=${uuid}`); let refName = chosenCity; refName = refName.replace(/[^a-z0-9 ...
Read more >
Announcing React Native 0.69
On React Native 0.69, React 18 is enabled by default. However, if you have not migrated to the New Architecture, you will only...
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