I have a google cloud function that gets triggered asynchronously when an user gets created (from Firebase SDK). Function gets executed, but it seems it doesn't resolve because it reaches the timeout and it produces an error on client side, and account doesn't get created.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.myFunction = functions.auth.user().onCreate((user) => {
console.log(user.uid);
return new Promise((resolve, reject) => { resolve(); });
});
On my client app (ReactJS) I get this as Cloud Function fails to resolve:
{code: "auth/internal-error", message: "Cloud function deadline exceeded.", a: null}
And on my cloud function logs I get this (thinking that, for some reason my code was taking too much, even increased the time to 360 seconds):
Function execution took 360002 ms, finished with status: 'timeout'
Why is the promise return not resolving the execution of my promise? I also tried by returning true or returning an integer, without success.
EDIT: Adding client-side code.
This is the code on client side (Using Firebase SDK). I'm not expecting a response from backend. If I remove the trigger in Firebase to the Cloud Function, user creation works fine (I get an object containing user info):
import firebase from 'firebase';
firebase.initializeApp(firebaseConfig);
firebase.auth().tenantId = 'tenant-1'; //Using Google Identity provider
const response = await firebase.auth().createUserWithEmailAndPassword(email, password);