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

Uncaught Error: Callback was already called.

Open cope opened this issue 7 years ago • 3 comments

activedirectory: "^0.7.2"

When calling getUsersForGroup('allusers'):

Uncaught Error: Callback was already called.
  (anonymous function)	
  (anonymous function)	
  (anonymous function)	
  onSearch	
  onClientError	
  emitOne	
  emit	
  onSocketError	
  emitOne	
  emit	
  emitErrorNT	
  _combinedTickCallback	
  _tickDomainCallback	
Debugger attached.
C:\git\systools\fusion\node_modules\activedirectory\node_modules\async\dist\async.js:955
        if (fn === null) throw new Error("Callback was already called.");
                         ^

Error: Callback was already called.
    at C:\git\systools\fusion\node_modules\activedirectory\node_modules\async\dist\async.js:955:32
    at C:\git\systools\fusion\node_modules\activedirectory\lib\activedirectory.js:1051:15
    at C:\git\systools\fusion\node_modules\activedirectory\lib\activedirectory.js:979:21
    at onSearch (C:\git\systools\fusion\node_modules\activedirectory\lib\activedirectory.js:1524:21)
    at Client.onClientError (C:\git\systools\fusion\node_modules\activedirectory\lib\activedirectory.js:493:19)
    at emitOne (events.js:116:13)
    at Client.emit (events.js:211:7)
    at Socket.onSocketError (C:\git\systools\fusion\node_modules\ldapjs\lib\client\client.js:1169:12)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
Waiting for the debugger to disconnect...

Process finished with exit code 1

Or this way:

Debugger attached.
C:\git\systools\fusion\node_modules\activedirectory\node_modules\async\dist\async.js:955
        if (fn === null) throw new Error("Callback was already called.");
                         ^

Error: Callback was already called.
    at C:\git\systools\fusion\node_modules\activedirectory\node_modules\async\dist\async.js:955:32
    at C:\git\systools\fusion\node_modules\activedirectory\lib\activedirectory.js:1058:11
    at C:\git\systools\fusion\node_modules\activedirectory\node_modules\async\dist\async.js:473:16
    at iteratorCallback (C:\git\systools\fusion\node_modules\activedirectory\node_modules\async\dist\async.js:1050:13)
    at C:\git\systools\fusion\node_modules\activedirectory\node_modules\async\dist\async.js:958:16
    at C:\git\systools\fusion\node_modules\activedirectory\lib\activedirectory.js:1045:13
    at C:\git\systools\fusion\node_modules\activedirectory\node_modules\async\dist\async.js:3096:16
    at eachOfArrayLike (C:\git\systools\fusion\node_modules\activedirectory\node_modules\async\dist\async.js:1055:9)
    at eachOf (C:\git\systools\fusion\node_modules\activedirectory\node_modules\async\dist\async.js:1103:5)
    at Object.eachLimit (C:\git\systools\fusion\node_modules\activedirectory\node_modules\async\dist\async.js:3158:5)
    at onSearch (C:\git\systools\fusion\node_modules\activedirectory\lib\activedirectory.js:1039:15)
    at onSearchEnd (C:\git\systools\fusion\node_modules\activedirectory\lib\activedirectory.js:506:21)
    at EventEmitter.<anonymous> (C:\git\systools\fusion\node_modules\activedirectory\lib\activedirectory.js:540:7)
    at emitOne (events.js:116:13)
    at EventEmitter.emit (events.js:211:7)
    at sendResult (C:\git\systools\fusion\node_modules\ldapjs\lib\client\client.js:1389:22)
    at messageCallback (C:\git\systools\fusion\node_modules\ldapjs\lib\client\client.js:1421:16)
    at Parser.onMessage (C:\git\systools\fusion\node_modules\ldapjs\lib\client\client.js:1089:14)
    at emitOne (events.js:116:13)
    at Parser.emit (events.js:211:7)
    at Parser.write (C:\git\systools\fusion\node_modules\ldapjs\lib\messages\parser.js:111:8)
    at end (C:\git\systools\fusion\node_modules\ldapjs\lib\messages\parser.js:66:19)
Uncaught Error: Callback was already called.
  (anonymous function)	
  (anonymous function)	
  (anonymous function)	
  iteratorCallback	
  (anonymous function)	
  (anonymous function)	
  (anonymous function)	
  eachOfArrayLike	
  eachOf	
  eachLimit	
  onSearch	
  onSearchEnd	
  (anonymous function)	
  emitOne	
  emit	
  sendResult	
  messageCallback	
  onMessage	
  emitOne	
  emit	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	Waiting for the debugger to disconnect...

  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  end	
  Parser.write	
  onData	
  emitOne	
  emit	
  addChunk	
  readableAddChunk	
  Readable.push	
  onread	

Process finished with exit code 1

Where Parser.write/end errors had this on the right (don't know why this didn't copy over): image image

Interestingly, when I replace allusers with some small DL, like 11 users, then it works fine. So, now I don't know if the size of allusers is the problem or something else :(

cope avatar Mar 20 '18 16:03 cope

dup of #70 but I'm running into the same issue.

simonmilz avatar Apr 16 '18 10:04 simonmilz

Same issue here. It seems like the problem occurs every time you make a function that calls multiple instances for a lookup at once (strangely just for findGroups, for findUser it works just fine).

I made a workaround which makes sure that only one request is worked on at any given time. This works but it's far from perfect perfomance wise.

I guess the key would be to get rid of the async-lib and use promises instead.

relief-melone avatar Aug 01 '18 09:08 relief-melone

I think I was right. Forked it and started to restructure the code (a little more microservice approach to get rid of the 2000+ lines of code) Also finished the GetUsersForGroup Method as promise based and without the use of the async library (so still alot of work to do, but its a start). Now accepts a callback as well as returning a promise. It's published here

https://github.com/relief-melone/node-activedirectory

I will probably work on the other methods and if there's a need for it I will publish it on npm

relief-melone avatar Aug 01 '18 20:08 relief-melone