Skip to content

Commit

Permalink
Proper handling of errors in cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Nov 18, 2023
1 parent af46df6 commit 3e29586
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions read.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ export function addReadMethods(LMDBStore, {
keySize = iterate(cursorAddress);
if (keySize <= 0 ||
(count++ >= limit)) {
if (count < 0)
lmdbError(count);
if (keySize < -30700 && keySize !== -30798)
lmdbError(keySize);
finishCursor();
return ITERATOR_DONE;
}
Expand Down Expand Up @@ -818,7 +818,8 @@ Txn.prototype.done = function() {
if (this.refCount === 0 && this.notCurrent) {
this.abort();
this.isDone = true;
}
} else if (this.refCount < 0)
throw new Error('Can not finish a transaction more times than it was used');
}
Txn.prototype.use = function() {
this.refCount = (this.refCount || 0) + 1;
Expand Down

0 comments on commit 3e29586

Please sign in to comment.