From c2b7768c8a163b32a77e0f0d9bd7b83d1b733b96 Mon Sep 17 00:00:00 2001 From: Chris Wendt Date: Mon, 15 Jan 2024 23:03:11 -0700 Subject: [PATCH] fix stack overflow --- lib/datastore.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/datastore.js b/lib/datastore.js index 740abf8..92fed60 100755 --- a/lib/datastore.js +++ b/lib/datastore.js @@ -668,7 +668,7 @@ class Datastore extends EventEmitter { * @private */ async _getCandidatesAsync (query, dontExpireStaleDocs = false) { - const validDocs = [] + let validDocs = [] // STEP 1: get candidates list by checking indexes from most to least frequent usecase const docs = this._getRawCandidates(query) @@ -684,7 +684,7 @@ class Datastore extends EventEmitter { for (const _id of expiredDocsIds) { await this._removeAsync({ _id }, {}) } - } else validDocs.push(...docs) + } else validDocs = docs return validDocs }