From cde01e744e2e1722814dcad631a81fe267305b17 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Wed, 17 Jan 2024 06:25:50 -0700 Subject: [PATCH] Add bad transaction warnings --- package.json | 2 +- read.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0d09e440c..eecd88bf3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lmdb", "author": "Kris Zyp", - "version": "2.9.3-beta.4-debug", + "version": "2.9.3-beta.5-debug", "description": "Simple, efficient, scalable, high-performance LMDB interface", "license": "MIT", "repository": { diff --git a/read.js b/read.js index 2df1ecc72..ba762e69a 100644 --- a/read.js +++ b/read.js @@ -94,6 +94,9 @@ export function addReadMethods(LMDBStore, { let txn = env.writeTxn || (options && options.transaction) || (readTxnRenewed ? readTxn : renewReadTxn(this)); txn.refCount = (txn.refCount || 0) + 1; outstandingReads++; + if (!txn.address) { + throw new Error('Invalid transaction, it has no address'); + } let address = recordReadInstruction(txn.address, this.db.dbi, id, this.writeKey, maxKeySize, ( rc, bufferId, offset, size ) => { if (rc && rc !== 1) callback(lmdbError(rc)); @@ -412,6 +415,9 @@ export function addReadMethods(LMDBStore, { if (txn.isDone) throw new Error('Can not iterate on range with transaction that is already' + ' done'); txnAddress = txn.address; + if (!txnAddress) { + throw new Error('Invalid transaction, it has no address'); + } cursor = null; } else { let writeTxn = env.writeTxn;