Node-ldapjs: Unbind not working with node 10

Created on 7 Jun 2018  路  8Comments  路  Source: ldapjs/node-ldapjs

When I try to use ldapjs client.unbind with node 10.0.0 (or 10.4.0) it does not work and the callback of unbind is never called. I debugged and it seems something in _sendSocket stops working, the function messageCallback is never called. While debugging it worked sometimes and the UnbindResponse was received successfully, but most of the time it didn't work, so I was wondering if it might be some timing issue, as while debugging everything runs slower/stepped.

The last trace log I see is:

{"name":"ldapjs","component":"client","hostname":"abc","pid":60921,"clazz":"Client","ldap_id":"6__ldaps://ldap.domain.net","level":10,"msg":"sending request {\"messageID\":3,\"protocolOp\":\"UnbindRequest\",\"controls\":[]}","time":"2018-06-07T10:39:44.165Z","v":0}

The code is

            client.search(
                'ou=domain,dc=sub,dc=net',
                opts, (err, res) => {
                    if (err) {
                        cb(err, null);
                        return;
                    }
                    res.on(
                        'searchEntry', entry => {
                            if (entry.object.hasOwnProperty('mail')) {
                                retrievedUsers[entry.object.uid] = entry.object;
                            }
                        }
                    );
                    res.on(
                        'error', err => {
                            cb(err, null);
                            client.unbind(
                                err => {
                                    if (err) {
                                        logger.error(err);
                                    }
                                }
                            );
                        }
                    );
                    res.on(
                        'end', () => {
                            client.unbind(
                                err => { // << --- never called
                                    cb(err, retrievedUsers);
                                }
                            );
                        }
                    );
                }
            );

Most helpful comment

@purplemana It's fixed with https://www.npmjs.com/package/ldapts, if you want to give that a go.

All 8 comments

The same applies to node 10.4.1

I can confirm that that unbind callback isn't being called in node any v10. The last working version was node v9.

There's a pull request attempting to fix this (https://github.com/joyent/node-ldapjs/pull/485) but it's failing some tests still.

Pardon the pun but I am really in a bind to get this fix :). @jgeurts: Would you mind giving a fork?

I believe this issue is caused by some weird behavior of Nodejs 10. Opened https://github.com/nodejs/node/issues/24577

@purplemana It's fixed with https://www.npmjs.com/package/ldapts, if you want to give that a go.

@jgeurts I just switched to using ldapts package instead. Ended up producing better code and easier to test and works with node 11.

Please track #524.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abarik1981 picture abarik1981  路  4Comments

jjayaraman picture jjayaraman  路  5Comments

gdw2 picture gdw2  路  3Comments

narendrachoudhary picture narendrachoudhary  路  7Comments

sean256 picture sean256  路  5Comments