Skip to content

Commit

Permalink
Do not attempt to finish/complete a cursor/txn twice for the same ite…
Browse files Browse the repository at this point in the history
…rator
  • Loading branch information
kriszyp committed Feb 6, 2024
1 parent 4b06676 commit 1eb9973
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lmdb",
"author": "Kris Zyp",
"version": "2.10.0-beta.2",
"version": "2.10.0-beta.3",
"description": "Simple, efficient, scalable, high-performance LMDB interface",
"license": "MIT",
"repository": {
Expand Down
6 changes: 5 additions & 1 deletion read.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ export function addReadMethods(LMDBStore, {
}

function finishCursor() {
if (txn.isDone)
if (!cursor || txn.isDone)
return;
if (iterable.onDone)
iterable.onDone()
Expand All @@ -511,6 +511,7 @@ export function addReadMethods(LMDBStore, {
db.cursorTxn = txn;
}
}
cursor = null;
}
return {
next() {
Expand All @@ -519,6 +520,9 @@ export function addReadMethods(LMDBStore, {
resetCursor();
keySize = position(0);
}
if (!cursor) {
return ITERATOR_DONE;
}
if (count === 0) { // && includeValues) // on first entry, get current value if we need to
keySize = position(options.offset);
} else
Expand Down

0 comments on commit 1eb9973

Please sign in to comment.