Call waitForPendingUpdates() and wait for the resulting promise.
waitForPendingUpdates()
https://firebase.google.com/docs/reference/js/firestore_.md#waitforpendingwrites_231a8e0