From 1eb99738b3bdadbe1955879b2c360025d8284a91 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Tue, 6 Feb 2024 10:08:31 -0700 Subject: [PATCH] Do not attempt to finish/complete a cursor/txn twice for the same iterator --- package.json | 2 +- read.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8686b9301..49c954134 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/read.js b/read.js index 19a84bca1..0dfafba3d 100644 --- a/read.js +++ b/read.js @@ -490,7 +490,7 @@ export function addReadMethods(LMDBStore, { } function finishCursor() { - if (txn.isDone) + if (!cursor || txn.isDone) return; if (iterable.onDone) iterable.onDone() @@ -511,6 +511,7 @@ export function addReadMethods(LMDBStore, { db.cursorTxn = txn; } } + cursor = null; } return { next() { @@ -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