-
Notifications
You must be signed in to change notification settings - Fork 78
Description
If the ldap client periodically closes idle connections, an error event will bubble up from ldapjs to the top of the stack & kill the process. We see this with ECONNRESET errors that terminate the process.
Thing is, this module will check if it has a connection open and if not open it whenever calling into authenticate.... the best way to deal with it seems to be to attach a dummy error handler to the client:
const ldapClient = LdapClient({...options})
ldapClient.on('error', () => { console.log('worry not!' }) // <-- clients need this or risk process termination
module.exports = (req, res, next) => {
ldapClient.authenticate(uname, password, (err, user) => {
if (err) { return next(err) } // <-- errors from reconnect after failed connection are handled here
req.user = user
next()
})
})Or, if the library wants to handle it - it just needs to not re-emit the error event here:
https://github.com/vesse/node-ldapauth-fork/blob/v4.0.2/lib/ldapauth.js#L158
I'm not sure if there are things I'm missing here, so it might be best to leave this to the client to handle... hence my first comment on add this to the basicAuth example in the readme.