From 885ee61d2ff3a164da57035cae3d713aef72ba87 Mon Sep 17 00:00:00 2001 From: David Beitey Date: Mon, 16 Oct 2017 17:30:20 +1000 Subject: [PATCH] Resolve promise on size limit 'error' --- index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index.js b/index.js index 1f15bac..ad1a06a 100644 --- a/index.js +++ b/index.js @@ -41,6 +41,7 @@ Client.prototype.search = function (base, options, controls) { var searchCallback = function (err, result) { var r = { entries: [], + hitSizeLimit: false, references: [] }; @@ -53,6 +54,12 @@ Client.prototype.search = function (base, options, controls) { }); result.on('error', function (err) { + if (options.sizeLimit && err.name === 'SizeLimitExceededError') { + // Swallow error on limiting result size if we are limited + // See https://github.com/mcavage/node-ldapjs/issues/236 + r.hitSizeLimit = true + resolve(r); + } reject(err); });