Skip to content

Commit

Permalink
Add bad transaction warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Jan 17, 2024
1 parent 5fa9777 commit cde01e7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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.9.3-beta.4-debug",
"version": "2.9.3-beta.5-debug",
"description": "Simple, efficient, scalable, high-performance LMDB interface",
"license": "MIT",
"repository": {
Expand Down
6 changes: 6 additions & 0 deletions read.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit cde01e7

Please sign in to comment.