M Abbas
M Abbas

Reputation: 6479

Firebase cloud function is not triggered on user deletion

I've created a firebase cloud function to be triggered on user deletion, as mentioned in the firebase documentation:

const admin = require('firebase-admin');
const functions = require('firebase-functions');
const firestore = admin.firestore();
admin.initializeApp();

exports.deleteUserData = functions.auth.user().onDelete((event) => {
  const uid = event.uid;
  const firestorePromise = clearFirestoreData(uid);

  return Promise.all([firestorePromise])
      .then(() => console.log(`Successfully removed data for user #${uid}.`)
  );
});

After deleting the user from my iOS application, by calling:

user.reauthenticate(with: credential) { result, error in
    if let error = error {
        completion(error)
    } else {
        user.delete { error in
            if let error = error {
                completion(error)
            } else {
                completion(nil)
            }
        }
    }
}

In firebase, the user is deleted from "Authentication", but the function is not triggered.

If I delete the user directly from "Authentication" in the firebase console, the function is triggered and deletes the user's data successfully.

I am using:

"firebase-admin": "^8.8.0",
"firebase-functions": "^3.1.0"

Upvotes: 3

Views: 1177

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317467

Others have reported the same issue. See the discussion here.

This seems like a bug with the Cloud Functions. If that's the case, then there's nothing Stack Overflow can help with.

I will encourage you to file a bug report directly with Firebase support so they can collect data and escalate to engineering.

Upvotes: 2

Related Questions