Ville Myrskyneva
Ville Myrskyneva

Reputation: 1640

ldapjs error in server.js

I received this error:

/home/user/node_modules/ldapjs/lib/server.js:65
throw new TypeError('Invalid argument type: ' + typeof (argv[i]));
        ^
TypeError: Invalid argument type: undefined
at mergeFunctionArgs (/home/user/node_modules/ldapjs/lib/server.js:65:13)
at Server._mount (/home/user/node_modules/ldapjs/lib/server.js:814:35)
at Server.add (/home/user/node_modules/ldapjs/lib/server.js:500:15)
at Object.<anonymous> (/home/user/workspace/ldap/ldap.js:34:8)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)

when attempting to do the tests on ldapjs guide.

This error pretty much blocks on doing further testing since the service won't start.

Upvotes: 0

Views: 828

Answers (2)

Esailija
Esailija

Reputation: 140220

You are passing pre to ldapjs before it has been assigned the array of functions (I.E. it is undefined at the time). Variable and functions declarations are hoisted to the top, but assignments are not.

Move this

133. var pre = [authorize, loadPasswdFile];

To the top, or at least before you pass it to ldapjs.

The assignment is currently happening on line 133, but you are already passing it on line 34:

34. server.add('ou=users, o=myhost', pre, function(req, res, next) 

Btw, you should be able to see better where errors originate from by setting this at the start of the code:

Error.stackTraceLimit = Infinity;

Upvotes: 1

Ville Myrskyneva
Ville Myrskyneva

Reputation: 1640

My "solution" was to comment out the line whole together. It surely is not the right way to have it fixed, but at least the service starts then.

Upvotes: 0

Related Questions