4

I am programming an app with React Native. To use Firebase in this app, I installed the React Native Firebase npm package. I have set up everything to make requests to Firebase functions and this works smoothly. I am currently trying to set up the Firebase functions emulator to make my dev journey easier. But I can't seem to connect to the emulator.

Client

import functions from '@react-native-firebase/functions';

const DEV = true
if (DEV) {
  functions().useEmulator("192.168.x.x", 5001);
}

const sayHelloWorld = () =>{
  functions()
    .httpsCallable('helloWorld')()
        .then(response => {
            console.log(response.data)
        });
}

sayHelloWorld()

Backend Function

exports.helloWorld = functions.https.onRequest((request, response) => {
    response.status(200).send({"data":"Say hello world"});
});

I am using the useEmulator function to switch to the emulator running on port 5001. I am not using useFunctionEmulator as shown in the documentation (https://rnfirebase.io/functions/usage) because it appears to be outdated, but I tried it, and it doesn't work as well. I am using my local IP address for the host because I am running a physical android device. I have no issue running the app, but as soon as I execute the function request nothing happens and after one minute I get the following error message:

Possible Unhandled Promise Rejection (id: 0):     
Error: DEADLINE_EXCEEDED
Error: DEADLINE_EXCEEDED
callFirebaseFunctions@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mmm.sophia&modulesOnly=false&runModule=true:116187:60
_performTransitionSideEffects@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mmm.sophia&modulesOnly=false&runModule=true:65273:22       
_receiveSignal@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mmm.sophia&modulesOnly=false&runModule=true:65215:45
onResponderRelease@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mmm.sophia&modulesOnly=false&runModule=true:65055:34
invokeGuardedCallbackProd@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mmm.sophia&modulesOnly=false&runModule=true:3940:21
invokeGuardedCallback@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mmm.sophia&modulesOnly=false&runModule=true:4044:42
invokeGuardedCallbackAndCatchFirstError@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mmm.sophia&modulesOnly=false&runModule=true:4048:36
executeDispatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mmm.sophia&modulesOnly=false&runModule=true:4124:48
executeDispatchesInOrder@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mmm.sophia&modulesOnly=false&runModule=true:4144:26
executeDispatchesAndRelease@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.mmm.sophia&modulesOnly=false&runModule=true:5493:35
forEach@[native code]

The emulator logs do not show any activity.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
FriendlyMushroom
  • 178
  • 1
  • 10

0 Answers0