Skip to content
This repository has been archived by the owner on Sep 30, 2023. It is now read-only.

onEmpty -> onIdle #91

Merged
merged 1 commit into from
Apr 11, 2020
Merged

Conversation

tabcat
Copy link
Contributor

@tabcat tabcat commented Apr 11, 2020

This pr fixes a mistake i made in #85

As seen here https://github.com/sindresorhus/p-queue#onempty and comparing onEmpty and onIdle:

.onEmpty will resolve when the queue is emptied, or when the last promise in the queue has been called.
.onIdle will resolve when the queue is completely done, or when the last promise in the queue has been called and has resolved.

.onIdle is the behavior I thought .onEmpty had but recently I looked at p-queue again and saw the difference.

the issue with using onEmpty here is we could still see some errors it was brought into prevent. onIdle would cover these cases where orbitdb closes the cache before the last _addOperation call in queue has resolved.

This pr changes the await this._opqueue.onEmpty() line in the close method to await this._opqueue.onIdle() so that the store does not close until the queue is emptied and all _addOperations are resolved.

@aphelionz aphelionz merged commit 649ee15 into orbitdb-archive:master Apr 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants