Newly generated document ids are often broken:

I'm having around 300 records in my database.
Seems like generateSmallerId returns undefined sometimes. Didn't dig much into this and just replaced it with db.collection(path).doc().id, but the issue is that it's used to retain the documents order. So we need to find a proper solution.