0

I am attempting to delete all subcollections of a firestore document in React Native, using the firebase cloud functions recursiveDelete() method. When the function is called, it fails with

[Unhandled promise rejection: RangeError: Maximum call stack size exceeded.]
at [native code]:null in map
at [native code]:null in map
.
.
.
at [native code]:null in map

There is very little documentation on this function, in fact, it is not even mentioned in the official firebase docs. It is only documented here https://googleapis.dev/nodejs/firestore/4.15.1/Firestore_.html#recursiveDelete. People from this discussion seemed to have success with this function.

I implemented my function following the documentation's instructions, so this error confuses me, especially since I was under the impression the entire point of this function was to avoid exceeding the maximum call stack size.

This is my cloud function that calls recursiveDelete():

exports.deleteSubs = functions.https.onCall(async(data, context)=>{
    await firestore.recursiveDelete(data.path)
})

and the front-end code which calls the cloud function

var functions = firebase.functions()
let deleteFn = functions.httpsCallable('deleteSubs');

let ref = db.collection("Posts").doc(post.key)
deleteFn({path: ref})

This error occurs with and without the optional bulkWriter included in the docs example.

It also fails on documents with no nested subcollections (which makes me confused on how the stack size is being exceeded).

I have verified that the path being passed in is correct.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
maniha
  • 1
  • 1
  • You're not returning anything on your `deleteSubs()` function. Add a return and check if it still produces the error. – Marc Anthony B Jul 18 '22 at 05:00
  • I tried returning the promise created by recursiveDelete(), as well as simply returning "success", each of which had no difference on the error – maniha Jul 18 '22 at 18:15

0 Answers0