Skip to content

Commit

Permalink
AsyncIterator _end race condition workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
gsvarovsky committed Dec 27, 2020
1 parent 6185bf7 commit cf6f2ac
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/get/leveliterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ export class LevelIterator extends BufferedIterator<Quad> {


protected _end(destroy?: boolean) {
super._end(destroy);
if (!destroy) {
this.level.end((endErr?: Error) => {
if (endErr) {
this.emit('error', endErr);
}
});
if (!this.ended) {
super._end(destroy);
if (!destroy) {
this.level.end((endErr?: Error) => {
if (endErr) {
this.emit('error', endErr);
}
});
}
}
}

Expand Down

0 comments on commit cf6f2ac

Please sign in to comment.