node-ldapjs icon indicating copy to clipboard operation
node-ldapjs copied to clipboard

Client event routing issue

Open Yug-Damon opened this issue 1 year ago • 4 comments

EDIT: My environment osixia/openldap + ldapjs:3.0.5 the error is happening on a LDAP SEARCH query


File ./lib/client/client.js Line 1260

let event = msg.constructor.name
// Generate the event name for the event emitter, i.e. "searchEntry"
// and "searchReference".
event = (event[0].toLowerCase() + event.slice(1)).replaceAll('Result', '')
return sendResult(event, msg)

For some reason event[0] is undefined and therefore my app crashes on the toLowerCase call

I suggest to replace the if block with:

if(msg instanceof SearchEntry) {
      return sendResult('searchEntry', msg)
} else if(msg instanceof SearchReference) {
      return sendResult('searchReference', msg)
} else {
    ...
}

I think it's a terrible idea to base decision on constructor.name value. I've struggled 2.5 days to figure it out.

Yug-Damon avatar Sep 28 '23 18:09 Yug-Damon

Please provide a minimal reproducible example. Doing so will help us diagnose your issue. It should be the bare minimum code needed to trigger the issue, and easily runnable without any changes or extra code.

You may use a GitHub repository to host the code if it is too much to fit in a code block (or two).

jsumners avatar Sep 28 '23 18:09 jsumners

Hello, same error for me and here

melissakintz avatar Oct 01 '23 14:10 melissakintz

@melissakintz yes that's actually a post of mine, I'm gonna mark it as resolved and link the post to this ticket

Yug-Damon avatar Oct 01 '23 14:10 Yug-Damon

We had the same problem and applied the patch mentioned above using a nifty NPM module called patch-package to persist it across our development team.

if(msg instanceof SearchEntry) { return sendResult('searchEntry', msg) } else if(msg instanceof SearchReference) { return sendResult('searchReference', msg)

This package unmodified works on Node18 on Windows but when we deploy to our node image running on ocp 3.11 on a container the issue the OP occurs.

By applying the fix our NextAuth works flawlessly. I suggest perhaps taking a closer look at this issue.

DukeVenator avatar Dec 14 '23 00:12 DukeVenator