typesense / firestore-typesense-search

Firebase Extension to automatically push Firestore documents to Typesense for full-text search with typo tolerance, faceting, and more
https://extensions.dev/extensions/typesense/firestore-typesense-search
Apache License 2.0
150 stars 27 forks source link

Is the backfill batching logic fully correct ? #37

Closed sreenath-n closed 1 year ago

sreenath-n commented 1 year ago

Considering the order of execution of async functions in the Node.js Event Loop, is the backfill batching logic fully correct?

let currentDocumentsBatch = [];
querySnapshot.forEach(async ....); // this inner async functions might get executed after next line after the forEach()
if (currentDocumentsBatch.length > 0) { // this line might get executed before above inner async functions
jasonbosco commented 1 year ago

Thank you for catching this. I was going off of the documentation here... but I have indeed run into this issue with forEach and async functions in the past. I've gone ahead and pushed out v0.4.1 of the extension which now uses for...of instead.