-
Notifications
You must be signed in to change notification settings - Fork 458
How to clean up nicely #767
Comments
The |
It's been a LONG time since I raised this, but I think my problem is that calling const ldapjs = require('ldapjs');
let client = ldapjs.createClient({
url: "ldap://ldap.forumsys.com"
})
client.on('close', function(){
console.log("connection closed")
})
client.on('connect', function(){
console.log("connected")
const options = {
filter: 'uid=',
scope: 'sub'
}
client.search("dc=example,dc=com",options, function(err, res) {
if (err) {
console.log("Error in search callback")
console.log(err)
try {
console.log("calling unbind")
client.unbind();
} catch (error) {
console.log("second error")
console.log(error)
}
} else {
res.on('searchEntry', function(entry){
})
res.on('error', function(error){
})
res.on('end', function(result){
})
}
});
}) Which give the following output:
Why is the search callback being triggered twice? |
🤔 Likely a bug. If I'm not mistaken, there's an internal tracking of pending messages. This queue could be emptied in the Ideally, we'd add a failing integration test in out integration suite and solve from there. |
👋 On February 22, 2023, we released version 3 of this library. As a result, we are closing this issue/pull request. Please see issue #839 for more information, including how to proceed if you feel this closure is in error. |
Calling
client.search(base,opts, function(err, res){})
with a malformed filter (e.g.(uid=)
) means you can't clean up the client connection without triggering an error as the outstanding search message's error callback is triggered.When
client.ubind()
called there is still a message on the queue. Has the search not returned anerr
then I could have used themessageID
withclient.abandon()
but I can't see how to clear the message queue without an id.Example
The text was updated successfully, but these errors were encountered: