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

Firebase Firestore: Can't find variable: crypto #7507

Closed
RazaShehryar opened this issue Mar 27, 2020 · 36 comments Β· Fixed by #11692
Closed

Firebase Firestore: Can't find variable: crypto #7507

RazaShehryar opened this issue Mar 27, 2020 · 36 comments Β· Fixed by #11692

Comments

@RazaShehryar
Copy link

RazaShehryar commented Mar 27, 2020

πŸ‘‹ Hi there! Did you run into this error? Here's a quick shortcut to the workaround provided by @jan-kn

Downgrading to firebase@7.9.0 fixes the issue for me. Every release after that leads to either β€œatob” or β€œcrypto” missing


Original post:

Expo Diagnostics:

Expo CLI 3.16.1 environment info:
System:
OS: macOS 10.15.2
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.14.1 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6241897
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
npmPackages:
expo: ^36.0.2 => 36.0.2
react: ~16.9.0 => 16.9.0
react-native: https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz => 0.61.4
npmGlobalPackages:
expo-cli: 3.16.1

I am using Firebase Firestore services. I am getting the following error:

Can't find variable: crypto

  • node_modules/@firebase/firestore/dist/index.cjs.js:12207:5 in
  • node_modules/@firebase/firestore/dist/index.cjs.js:2276:27 in i.prototype.data
  • node_modules/@firebase/firestore/dist/index.cjs.js:7570:8 in t.prototype.initialize
  • node_modules/@firebase/firestore/dist/index.cjs.js:8187:5 in
  • node_modules/@firebase/firestore/dist/index.cjs.js:8179:28 in t.prototype.hf
  • node_modules/@firebase/firestore/dist/index.cjs.js:8240:45 in t
  • Screens/Dashboard.js:45:18 in
  • node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
  • node_modules/regenerator-runtime/runtime.js:274:30 in invoke
  • node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
  • node_modules/regenerator-runtime/runtime.js:135:28 in invoke
  • node_modules/regenerator-runtime/runtime.js:170:17 in PromiseImpl$argument_0
  • node_modules/promise/setimmediate/core.js:45:7 in tryCallTwo
  • node_modules/promise/setimmediate/core.js:200:23 in doResolve
  • node_modules/promise/setimmediate/core.js:66:12 in Promise
  • node_modules/regenerator-runtime/runtime.js:169:31 in PromiseImpl$argument_0
  • node_modules/regenerator-runtime/runtime.js:192:38 in enqueue
  • node_modules/regenerator-runtime/runtime.js:219:8 in exports.async
  • Screens/Dashboard.js:45:18 in
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:17029:10 in commitLifeCycles
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:20002:23 in commitLayoutEffects
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:307:15 in invokeGuardedCallbackImpl
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:531:36 in invokeGuardedCallback
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:19768:10 in commitRootImpl
  • [native code]:null in commitRootImpl
  • node_modules/scheduler/cjs/scheduler.development.js:643:23 in unstable_runWithPriority
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:19590:4 in commitRoot
  • [native code]:null in commitRoot
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18709:28 in runRootCallback
  • [native code]:null in runRootCallback
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5642:32 in runWithPriority$argument_1
  • node_modules/scheduler/cjs/scheduler.development.js:643:23 in unstable_runWithPriority
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5638:22 in flushSyncCallbackQueueImpl
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5627:28 in flushSyncCallbackQueue
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18556:30 in scheduleUpdateOnFiber
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:21822:15 in scheduleRootUpdate
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:23042:20 in ReactNativeRenderer.render
  • node_modules/react-native/Libraries/ReactNative/renderApplication.js:52:52 in renderApplication
  • node_modules/react-native/Libraries/ReactNative/AppRegistry.js:116:10 in runnables.appKey.run
  • node_modules/react-native/Libraries/ReactNative/AppRegistry.js:197:26 in runApplication
  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:436:47 in __callFunction
  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:111:26 in __guard$argument_0
  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
  • node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:110:17 in __guard$argument_0
  • [native code]:null in callFunctionReturnFlushedQueue

Here's my code:

const firebaseConfig = {
apiKey: "XXX",
authDomain: "XXX",
databaseURL: "XXX",
projectId: "XXX",
storageBucket: "XXX"
};

firebase.initializeApp(firebaseConfig);

const dbh = firebase.firestore();

try {
await dbh
.collection("Requests")
.doc("mario")
.set({
employment: "plumber",
outfitColor: "red",
specialAttack: "fireball"
});
} catch (error) {
console.log(error);
}

@RazaShehryar RazaShehryar changed the title Firebase Firestore: Can't find variable: Crypto Firebase Firestore: Can't find variable: crypto Mar 27, 2020
@mauriciord
Copy link
Contributor

@RazaShehryar Did you use?

import firebase from 'firebase';
import 'firebase/firestore';

@RazaShehryar
Copy link
Author

@RazaShehryar Did you use?

import firebase from 'firebase';
import 'firebase/firestore';

Yes I did exactly. Still facing the issue

@mauriciord
Copy link
Contributor

mauriciord commented Mar 27, 2020

@RazaShehryar Could you send a more detailed code here? It would be nice as a gist, please.

Why are you using with await?

@RazaShehryar
Copy link
Author

@mauriciord
Copy link
Contributor

mauriciord commented Mar 27, 2020

@RazaShehryar

import firebase from 'firebase';
import 'firebase/firestore';

I think you don't need the /app prefix, only import firebase from 'firebase'

@RazaShehryar
Copy link
Author

@RazaShehryar

import firebase from 'firebase';
import 'firebase/firestore';

I think you don't need the /app prefix, only import firebase from 'firebase'

I tried and not it says

_Firebase.default.firestore is not a function. (In '_Firebase.default.firestore()', '_Firebase.default.firestore' is undefined)

@brentvatne
Copy link
Member

@RazaShehryar - post a mcve (https://stackoverflow.com/help/mcve)

@RazaShehryar
Copy link
Author

RazaShehryar commented Mar 27, 2020

Oh well. I did some research and found out that there's some kind of bug with Firebase FB SDK with React Native. To resolve the issue, I had to include the following in my App.js.

import { decode, encode } from 'base-64'
global.crypto = require("@firebase/firestore");
global.crypto.getRandomValues = byteArray => { for (let i = 0; i < byteArray.length; i++) { byteArray[i] = Math.floor(256 * Math.random()); } }

if (!global.btoa) { global.btoa = encode; }

if (!global.atob) { global.atob = decode; }

Note: You'll need to install base-64 first (npm install base-64).

@ishaansehgal99
Copy link

ishaansehgal99 commented Mar 28, 2020

I am having this same exact issue.
Upon calling:

			Fire.shared
                .addUser(values)
                .then((response) => {
                    console.log(response);
                })
                .catch(error => {
                    console.log(error);
                    alert(error);
                });
    addUser = async ({firstName, lastName, email, role, zipCode, town}) => {
       return new Promise((resolve, reject) => {
          	firebase.firestore()
               .collection('users')
               .add({
                   firstName,
                   lastName,
                   email,
                   role,
                   zipCode,
                   town
               }).then(data => {
                   resolve(data)
               }) .catch(error => {
                   reject(error)
               });
       });
    }

@ishaansehgal99
Copy link

I resolved this issue @RazaShehryar using your code. In my config file I run:

     global.crypto = require("firebase/firestore");
     global.crypto.getRandomValues = byteArray => { for (let i = 0; i < byteArray.length; i++) { byteArray[i] = Math.floor(256 * Math.random()); } }
      if (!global.btoa) { global.btoa = encode; }
      if (!global.atob) { global.atob = decode; }

I understand how it works, this is used to generate the document id correct? Can you explain why I need to do this, however?

@caspg
Copy link

caspg commented Mar 29, 2020

I'm not really sure that Math.random() is a good way to go. It's not cryptographically secure.

Here is an issue with a similar problem: #7209.

@Sanan4li
Copy link

Oh well. I did some research and found out that there's some kind of bug with Firebase FB SDK with React Native. To resolve the issue, I had to include the following in my App.js.

import { decode, encode } from 'base-64'
global.crypto = require("@firebase/firestore");
global.crypto.getRandomValues = byteArray => { for (let i = 0; i < byteArray.length; i++) { byteArray[i] = Math.floor(256 * Math.random()); } }

if (!global.btoa) { global.btoa = encode; }

if (!global.atob) { global.atob = decode; }

Note: You'll need to install base-64 first (npm install base-64).

do you have any idea why we have to do all this.

@RazaShehryar
Copy link
Author

Oh well. I did some research and found out that there's some kind of bug with Firebase FB SDK with React Native. To resolve the issue, I had to include the following in my App.js.
import { decode, encode } from 'base-64'
global.crypto = require("@firebase/firestore");
global.crypto.getRandomValues = byteArray => { for (let i = 0; i < byteArray.length; i++) { byteArray[i] = Math.floor(256 * Math.random()); } }
if (!global.btoa) { global.btoa = encode; }
if (!global.atob) { global.atob = decode; }
Note: You'll need to install base-64 first (npm install base-64).

do you have any idea why we have to do all this.

I am not sure. For some reason, Firebase SDK isn't supported well for React Native. I am using Expo to build the app so I guess there won't be an issue if you are using react-native-firebase.

As @ishaansehgal99 stated, it is used to generate doc id.

@ahmadmshatat
Copy link

ahmadmshatat commented Mar 29, 2020

using react-native-firebase module solve the problem

https://invertase.io/oss/react-native-firebase/quick-start/existing-project

@RazaShehryar
Copy link
Author

RazaShehryar commented Mar 30, 2020

it works but it says :

Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module
awake, and timers can only be called when the app is in the foreground. See facebook/react-native#12981 for more info.
(Saw setTimeout with duration 442735ms)

  • node_modules\react-native\Libraries\YellowBox\YellowBox.js:71:8 in console.warn

  • node_modules\expo\build\environment\muteWarnings.fx.js:18:23 in warn

  • node_modules\react-native\Libraries\Core\Timers\JSTimers.js:242:8 in setTimeout

  • http://192.168.1.110:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:140043:15 in mc

  • node_modules@firebase\webchannel-wrapper\dist\index.js:26:270 in xb

  • node_modules@firebase\webchannel-wrapper\dist\index.js:25:457 in get

  • node_modules@firebase\webchannel-wrapper\dist\index.js:24:221 in

  • node_modules@firebase\webchannel-wrapper\dist\index.js:12:27 in

  • node_modules@firebase\webchannel-wrapper\dist\index.js:11:928 in Aa

  • node_modules@firebase\webchannel-wrapper\dist\index.js:40:283 in Hc

  • node_modules@firebase\webchannel-wrapper\dist\index.js:40:161 in Gc

  • http://192.168.1.110:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:140774:65 in Da

  • [native code]:null in

  • node_modules\event-target-shim\dist\event-target-shim.js:818:39 in EventTarget.prototype.dispatchEvent

  • node_modules\react-native\Libraries\Network\XMLHttpRequest.js:566:23 in setReadyState

  • node_modules\react-native\Libraries\Network\XMLHttpRequest.js:350:23 in __didReceiveIncrementalData

  • node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:190:12 in emit

  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction

  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0

  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard

  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0

  • [native code]:null in callFunctionReturnFlushedQueue

still a problem .. :(

To solve the problem, please go through this solution. It worked for me and now I am not getting any warnings.

firebase/firebase-js-sdk#97 (comment)

@RazaShehryar
Copy link
Author

it works but it says :
Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module
awake, and timers can only be called when the app is in the foreground. See facebook/react-native#12981 for more info.
(Saw setTimeout with duration 442735ms)

  • node_modules\react-native\Libraries\YellowBox\YellowBox.js:71:8 in console.warn
  • node_modules\expo\build\environment\muteWarnings.fx.js:18:23 in warn
  • node_modules\react-native\Libraries\Core\Timers\JSTimers.js:242:8 in setTimeout
  • http://192.168.1.110:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:140043:15 in mc
  • node_modules@firebase\webchannel-wrapper\dist\index.js:26:270 in xb
  • node_modules@firebase\webchannel-wrapper\dist\index.js:25:457 in get
  • node_modules@firebase\webchannel-wrapper\dist\index.js:24:221 in
  • node_modules@firebase\webchannel-wrapper\dist\index.js:12:27 in
  • node_modules@firebase\webchannel-wrapper\dist\index.js:11:928 in Aa
  • node_modules@firebase\webchannel-wrapper\dist\index.js:40:283 in Hc
  • node_modules@firebase\webchannel-wrapper\dist\index.js:40:161 in Gc
  • http://192.168.1.110:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:140774:65 in Da
  • [native code]:null in
  • node_modules\event-target-shim\dist\event-target-shim.js:818:39 in EventTarget.prototype.dispatchEvent
  • node_modules\react-native\Libraries\Network\XMLHttpRequest.js:566:23 in setReadyState
  • node_modules\react-native\Libraries\Network\XMLHttpRequest.js:350:23 in __didReceiveIncrementalData
  • node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:190:12 in emit
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0
  • [native code]:null in callFunctionReturnFlushedQueue

still a problem .. :(

To solve the problem, please go through this solution. It worked for me and now I am not getting any warnings.
https://github.com/firebase/firebase-js-sdk/issues/97#issuecomment-427512040

"No results matched your search"

link dont work can you help me via code or another way please i cant solve it :(

https://gist.github.com/RazaShehryar/350b439627a99796658d552fcd180b02

@andmar204
Copy link

it works but it says :
Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module
awake, and timers can only be called when the app is in the foreground. See facebook/react-native#12981 for more info.
(Saw setTimeout with duration 442735ms)

  • node_modules\react-native\Libraries\YellowBox\YellowBox.js:71:8 in console.warn
  • node_modules\expo\build\environment\muteWarnings.fx.js:18:23 in warn
  • node_modules\react-native\Libraries\Core\Timers\JSTimers.js:242:8 in setTimeout
  • http://192.168.1.110:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:140043:15 in mc
  • node_modules@firebase\webchannel-wrapper\dist\index.js:26:270 in xb
  • node_modules@firebase\webchannel-wrapper\dist\index.js:25:457 in get
  • node_modules@firebase\webchannel-wrapper\dist\index.js:24:221 in
  • node_modules@firebase\webchannel-wrapper\dist\index.js:12:27 in
  • node_modules@firebase\webchannel-wrapper\dist\index.js:11:928 in Aa
  • node_modules@firebase\webchannel-wrapper\dist\index.js:40:283 in Hc
  • node_modules@firebase\webchannel-wrapper\dist\index.js:40:161 in Gc
  • http://192.168.1.110:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:140774:65 in Da
  • [native code]:null in
  • node_modules\event-target-shim\dist\event-target-shim.js:818:39 in EventTarget.prototype.dispatchEvent
  • node_modules\react-native\Libraries\Network\XMLHttpRequest.js:566:23 in setReadyState
  • node_modules\react-native\Libraries\Network\XMLHttpRequest.js:350:23 in __didReceiveIncrementalData
  • node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:190:12 in emit
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:436:47 in __callFunction
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:26 in __guard$argument_0
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:384:10 in __guard
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:110:17 in __guard$argument_0
  • [native code]:null in callFunctionReturnFlushedQueue

still a problem .. :(

To solve the problem, please go through this solution. It worked for me and now I am not getting any warnings.
https://github.com/firebase/firebase-js-sdk/issues/97#issuecomment-427512040

"No results matched your search"
link dont work can you help me via code or another way please i cant solve it :(

https://gist.github.com/RazaShehryar/350b439627a99796658d552fcd180b02

I put this in my App.js file with no luck. Can you help me?

@pastorinoandres
Copy link

This worked for me πŸ’―

To sort this out you need to hard code the value, increase the value of the variable MAX_TIMER_DURATION_MS. Here are the steps:

Go to node_modules/react-native/Libraries/Core/Timer/JSTimers.js

Look for the variable MAX_TIMER_DURATION_MS

Change 60 * 1000 to 10000 * 1000

Save the changes and re-build your app.

From SohamToraskar
https://stackoverflow.com/a/46678121

@andmar204
Copy link

This worked for me πŸ’―

To sort this out you need to hard code the value, increase the value of the variable MAX_TIMER_DURATION_MS. Here are the steps:

Go to node_modules/react-native/Libraries/Core/Timer/JSTimers.js

Look for the variable MAX_TIMER_DURATION_MS

Change 60 * 1000 to 10000 * 1000

Save the changes and re-build your app.

From SohamToraskar
https://stackoverflow.com/a/46678121

Thanks, but I was referring to the "can't find variable crypto" problem haha

@RazaShehryar
Copy link
Author

This worked for me πŸ’―
To sort this out you need to hard code the value, increase the value of the variable MAX_TIMER_DURATION_MS. Here are the steps:
Go to node_modules/react-native/Libraries/Core/Timer/JSTimers.js
Look for the variable MAX_TIMER_DURATION_MS
Change 60 * 1000 to 10000 * 1000
Save the changes and re-build your app.
From SohamToraskar
https://stackoverflow.com/a/46678121

Thanks, but I was referring to the "can't find variable crypto" problem haha

Are you sure you are putting the mentioned gist in the top root of App.js?

@andmar204
Copy link

This worked for me πŸ’―
To sort this out you need to hard code the value, increase the value of the variable MAX_TIMER_DURATION_MS. Here are the steps:
Go to node_modules/react-native/Libraries/Core/Timer/JSTimers.js
Look for the variable MAX_TIMER_DURATION_MS
Change 60 * 1000 to 10000 * 1000
Save the changes and re-build your app.
From SohamToraskar
https://stackoverflow.com/a/46678121

Thanks, but I was referring to the "can't find variable crypto" problem haha

Are you sure you are putting the mentioned gist in the top root of App.js?

I think so, I only have one App.js file which is at the root of my project

@RazaShehryar
Copy link
Author

If you can show me your code, I might be able to help you out.

This worked for me πŸ’―
To sort this out you need to hard code the value, increase the value of the variable MAX_TIMER_DURATION_MS. Here are the steps:
Go to node_modules/react-native/Libraries/Core/Timer/JSTimers.js
Look for the variable MAX_TIMER_DURATION_MS
Change 60 * 1000 to 10000 * 1000
Save the changes and re-build your app.
From SohamToraskar
https://stackoverflow.com/a/46678121

Thanks, but I was referring to the "can't find variable crypto" problem haha

Are you sure you are putting the mentioned gist in the top root of App.js?

I think so, I only have one App.js file which is at the root of my project

If you can show me your code, I might be able to help you out.

@andmar204
Copy link

If you can show me your code, I might be able to help you out.

This worked for me πŸ’―
To sort this out you need to hard code the value, increase the value of the variable MAX_TIMER_DURATION_MS. Here are the steps:
Go to node_modules/react-native/Libraries/Core/Timer/JSTimers.js
Look for the variable MAX_TIMER_DURATION_MS
Change 60 * 1000 to 10000 * 1000
Save the changes and re-build your app.
From SohamToraskar
https://stackoverflow.com/a/46678121

Thanks, but I was referring to the "can't find variable crypto" problem haha

Are you sure you are putting the mentioned gist in the top root of App.js?

I think so, I only have one App.js file which is at the root of my project

If you can show me your code, I might be able to help you out.

Here's my App.js file: https://gist.github.com/andmar204/3a8b90afd2f46d4ec66539c8feed2b72

@RazaShehryar
Copy link
Author

If you can show me your code, I might be able to help you out.

This worked for me πŸ’―
To sort this out you need to hard code the value, increase the value of the variable MAX_TIMER_DURATION_MS. Here are the steps:
Go to node_modules/react-native/Libraries/Core/Timer/JSTimers.js
Look for the variable MAX_TIMER_DURATION_MS
Change 60 * 1000 to 10000 * 1000
Save the changes and re-build your app.
From SohamToraskar
https://stackoverflow.com/a/46678121

Thanks, but I was referring to the "can't find variable crypto" problem haha

Are you sure you are putting the mentioned gist in the top root of App.js?

I think so, I only have one App.js file which is at the root of my project

If you can show me your code, I might be able to help you out.

Here's my App.js file: https://gist.github.com/andmar204/3a8b90afd2f46d4ec66539c8feed2b72

Have you installed base-64? (npm install base-64)

@andmar204
Copy link

npm install base-64

I believe so, but I'll run the install command just in case

@andmar204
Copy link

If you can show me your code, I might be able to help you out.

This worked for me πŸ’―
To sort this out you need to hard code the value, increase the value of the variable MAX_TIMER_DURATION_MS. Here are the steps:
Go to node_modules/react-native/Libraries/Core/Timer/JSTimers.js
Look for the variable MAX_TIMER_DURATION_MS
Change 60 * 1000 to 10000 * 1000
Save the changes and re-build your app.
From SohamToraskar
https://stackoverflow.com/a/46678121

Thanks, but I was referring to the "can't find variable crypto" problem haha

Are you sure you are putting the mentioned gist in the top root of App.js?

I think so, I only have one App.js file which is at the root of my project

If you can show me your code, I might be able to help you out.

Here's my App.js file: https://gist.github.com/andmar204/3a8b90afd2f46d4ec66539c8feed2b72

Have you installed base-64? (npm install base-64)

Ok, so I ran npm install base-64 and ran my project, and I still get the error. I'm not sure if this will help, but here's my error screen.
image

@jan-kn
Copy link

jan-kn commented Mar 31, 2020

I have exactly the same problem. Downgrading to firebase@7.9.0 fixes the issue for me. Every release after that leads to either β€œatob” or β€œcrypto” missing

@brentvatne
Copy link
Member

i'd sugget opening an issue on firebase-js-sdk about this: https://github.com/firebase/firebase-js-sdk

@andmar204
Copy link

I have exactly the same problem. Downgrading to firebase@7.9.0 fixes the issue for me. Every release after that leads to either β€œatob” or β€œcrypto” missing

This worked! Thank you so much, I would've never thought of that.

@pastorinoandres
Copy link

In debug mode i haven't problem, but with debug mode disabled the error appears.

@brentvatne
Copy link
Member

brentvatne commented Apr 2, 2020

maybe we should make expo install firebase install a known compatible version... @IjzerenHein what do you think?

@RazaShehryar
Copy link
Author

RazaShehryar commented Apr 2, 2020

maybe we should make expo install firebase install a known compatible version... @IjzerenHein what do you think?

Just out of context question, when you guys are adding Phone Auth in expo? I can see that SDK 37 has been released but the documentation says it is still in testing mode?

@brentvatne
Copy link
Member

@RazaShehryar - @IjzerenHein is working on it! it's coming soon

@benedilson
Copy link

benedilson commented Apr 3, 2020

@RazaShehryar
var docData = {
stringExample: "Hello world!",
booleanExample: true,
numberExample: 3.14159265,
dateExample: firebase.firestore.Timestamp.fromDate(new Date("December 10, 1815")),
arrayExample: [5, true, "hello"],
nullExample: null,
objectExample: {
a: 5,
b: {
nested: "foo"
}
}
};
db.collection("data").doc("one").set(docData).then(function() {
console.log("Document successfully written!");
});

// Add a new document with a generated id.
var newCityRef = db.collection("cities").doc();

// later...
newCityRef.set(data);

https://firebase.google.com/docs/firestore/manage-data/add-data?hl=pt-br

@brentvatne
Copy link
Member

locking this thread temporarily, if you come here with this issue keep in mind the solution presented above:

Downgrading to firebase@7.9.0 fixes the issue for me. Every release after that leads to either β€œatob” or β€œcrypto” missing

@expo expo locked and limited conversation to collaborators Apr 3, 2020
@IjzerenHein
Copy link
Contributor

IjzerenHein commented Apr 3, 2020

Hey guys, we're working on getting this problem resolved! I've done some investigating and found that there have been regressions in the Firebase JS SDK recently which make Firestore break in the react-native environment.

Here are the versions that have been tested:

Firebase JS SDK iOS Android Notes
7.8.1 βœ… βœ…*
7.8.2 βœ… βœ…*
7.9.0 βœ… βœ…*
7.9.1 ❌ ❌ Breaks on: "can't find variable atob"
7.9.3 ❌ ❌ Breaks on: "can't find variable atob"
7.13.2 ❌ ❌ Breaks on Crypto: "undefined is not an object(evaluating Wu.getRandomValues)"
7.14.0 ❌ ❌* Breaks on: "can't find variable atob"
7.15.0 ❌ ❌* Breaks on: "can't find variable atob"
7.16.0 βœ… βœ…*
7.20.0 βœ… βœ…*
7.24.0 βœ… βœ…*
8.2.1 βœ… βœ…*
  • shows long setTimeout warnings on Android

Also, the problem does not happen when Debugging is enabled.

Because of this, please use firebase@7.9.0 or lower for now πŸ™

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.