I face the following issue since a few weeks (hasn't been an issue before):
1 .add(data)
const saveNewDoc = functions.https.onCall((data: NewDocWrite, context: CallableContext) => {
return adminDb
.collection(data.collectionPath)
.add(data.data)
})
Document gets successfully created but there's still an error "INTERNAL" returned to the client and also listed in the functions log:
Unhandled error RangeError: Maximum call stack size exceeded
at baseIteratee (/srv/node_modules/lodash/lodash.js:3464:26)
at getIteratee (/srv/node_modules/lodash/lodash.js:5932:33)
at Function.map (/srv/node_modules/lodash/lodash.js:9556:31)
at encode (/srv/node_modules/firebase-functions/lib/providers/https.js:236:18)
at /srv/node_modules/lodash/lodash.js:13402:38
at /srv/node_modules/lodash/lodash.js:4911:15
at baseForOwn (/srv/node_modules/lodash/lodash.js:2996:24)
at Function.mapValues (/srv/node_modules/lodash/lodash.js:13401:7)
at encode (/srv/node_modules/firebase-functions/lib/providers/https.js:242:18)
at /srv/node_modules/lodash/lodash.js:13402:38
2 .doc().set(data)
Replacing add() by doc().set() creates the document without any errors.
Any idea why this happens? The "workaround" is simple just using doc().set() but I wonder why there even is the add() then. Can't we just use doc().set() for any new document?