From df9ee3049891d159deb214a9bacbe0f34b7edef3 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Tue, 2 Jan 2024 21:15:31 -0700 Subject: [PATCH] Don't throw unnecessary when closing cursor --- src/cursor.cpp | 7 +++---- util/RangeIterable.js | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cursor.cpp b/src/cursor.cpp index fabcc391d..fc9dd212e 100644 --- a/src/cursor.cpp +++ b/src/cursor.cpp @@ -51,11 +51,10 @@ CursorWrap::~CursorWrap() { } Value CursorWrap::close(const CallbackInfo& info) { - if (!this->cursor) { - return throwError(info.Env(), "cursor.close: Attempt to close a closed cursor!"); + if (this->cursor) { + mdb_cursor_close(this->cursor); + this->cursor = nullptr; } - mdb_cursor_close(this->cursor); - this->cursor = nullptr; return info.Env().Undefined(); } diff --git a/util/RangeIterable.js b/util/RangeIterable.js index d0f858528..ce2bf6fd4 100644 --- a/util/RangeIterable.js +++ b/util/RangeIterable.js @@ -31,7 +31,9 @@ export class RangeIterable { } else { iteratorResult = iterator.next(); if (iteratorResult.then) { - if (!async) throw new Error('Can not synchronously iterate with asynchronous values'); + if (!async) { + throw new Error('Can not synchronously iterate with asynchronous values'); + } return iteratorResult.then(iteratorResult => this.next(iteratorResult), onError); } }