-
Notifications
You must be signed in to change notification settings - Fork 451
Client.search overwrites earlier searches before completion #278
Comments
I.e. Even though the LDAP client API appears to imply making multiple calls at once to the same client is possible, in actuality you have to wait for each search to end before starting the next search. |
It would be valuable to enable debug logging in ldapjs (via node-bunyan) to ensure that this issue is not caused by external control flow problems. |
I went to test this again to see if I could figure out the bunyan logger stuff and found the the order of the promises even affects whether they successfully finish or not. If the persons search is second the classes search never finishes. But if classes is second they both finish successfully. Weird. The persons search is expected to return oodles of records, the classes only 1. |
I have a log but I have to figure out how to redact it and still keep it useful for you, because it's full of personal information I can't expose (it's also 300 lines long because of the number of persons retrieved from LDAP). I can see both searches in the log. I can also see SearchEntries for the one that never emits events, as well, so it does ultimately get and parse that result from the server. Again the callbacks 'res' argument never triggers the appropriate events for some reason. |
After analyzing the logs myself it did end up being the external flow control. Something about running When I rewrote it as a flat promise it worked as expected. |
Hi @jvanalst, I'm having exactly the same problem as you. I tried to write a flat promise as you have suggested but no luck. It works fine when I'm using "ldap", but not "ldaps". I saw you are also using ldaps, could you provide some details on how you solved the problem, please? Thanks.
|
I create and end a new client as part of every search (promise). It's a bunch of overhead, but it seemed unavoidable. |
Please include a minimal reproducible example |
So I discovered that when I call LDAP search, if I do two searches in parallel (saying using Bluebird Promises), the first search never emits any events. There are no searchEntrys, no errors, and no end. It appears that even though API leaves the impression that you can perform two searches across the same client in parallel, you really can't the second search actually overwrites the first search, causing the first search to hang forever.
The text was updated successfully, but these errors were encountered: