[REQUIRED] Environment info
firebase-tools: 9.1.0
Platform: macOS
[REQUIRED] Test case
A. Cloud function set to trigger on document "write" events:
exports.onDocWrite = functions.firestore.document(
'/test-collection/{id}'
).onWrite(change => {
const orig = change.before.data();
console.log(orig);
return true;
});
B. Code that deletes a document to trigger onDocWrite
async function main () {
const ref = admin.firestore().doc(
'/test-collection/QdfGrVXTYqPqIOxuXpbp'
);
await ref.delete();
process.exit(0);
}
[REQUIRED] Steps to reproduce
- Create the
onDocWrite firestore cloud function and deploy to production environment
- Manually add a new document to test-collection
- Run code to delete the document and observe logged output
- Run code to delete the document again: no logged output
- Repeat the above steps against the emulated environment
[REQUIRED] Expected behavior
Emulated environment should produce no logged output when deleting a document that does not exist.
[REQUIRED] Actual behavior
Cloud function in emulated environment is triggered on delete of the document that does not exist. It logs "undefined" for the document's before.data().
i functions: Beginning execution of "onDocWrite"
i functions: Finished "onDocWrite" in ~1s
> undefined
[REQUIRED] Environment info
firebase-tools: 9.1.0
Platform: macOS
[REQUIRED] Test case
A. Cloud function set to trigger on document "write" events:
B. Code that deletes a document to trigger
onDocWrite[REQUIRED] Steps to reproduce
onDocWritefirestore cloud function and deploy to production environment[REQUIRED] Expected behavior
Emulated environment should produce no logged output when deleting a document that does not exist.
[REQUIRED] Actual behavior
Cloud function in emulated environment is triggered on delete of the document that does not exist. It logs "undefined" for the document's
before.data().