Skip to content

Commit

Permalink
Merge pull request #125 from m-ld/master
Browse files Browse the repository at this point in the history
Fix for a race condition around duplicate calls to the _end method of the AsyncIterator wrapper around LevelIterator
  • Loading branch information
jacoscaz committed Dec 29, 2020
2 parents 6185bf7 + cf6f2ac commit 2f2d555
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 2f2d555

Please sign in to comment.