sanity-io / sanity-algolia

Utilities for indexing Sanity documents in Algolia
MIT License
67 stars 16 forks source link

Fixed not waiting for result of deleteObjects #37

Closed hyldmo closed 1 year ago

hyldmo commented 1 year ago

for await is only useful if the iterable object is an async iterable, which Object.values(typeIndexMap) is not. As the actual promise is typeIndexConfig.index.deleteObjects(recordsToDelete), that meant that execution would resume no matter if that operation was completed (or threw an error) or not. This PR fixes this by awaiting the actual promise.

hyldmo commented 1 year ago

Note: I see #24 would also fix this issue, while also preventing duplicates in the array

runeb commented 1 year ago

Thank you for the PR @hyldmo . I will close this as a duplicate of #24