Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1048

TypeError: callback is not a function

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.2.29
    • Component/s: MongoDB 3.4
    • Labels:
    • Environment:
      Mongo server v3.4.5
      Lib mongodb v2.2.29
      Node v8.1.2

      I get very random behaviors from the driver when executing a lot of conccurent queries simultaniously.
      When executing a batch of ~1000 parallel queries, I get two different behaviours:

      • The task succeeds (~5% of the time)
      • I get the following error (with longjohn enabled):
      /home/admin/parser/attempt/node_modules/mongodb/lib/utils.js:120
            return value2 ? callback(err, value1, value2) :  callback(err, value1);
                                                             ^
      TypeError: callback is not a function
          at /home/admin/parser/attempt/node_modules/mongodb/lib/cursor.js:779:15
          at handleCallback (/home/admin/parser/attempt/node_modules/mongodb/lib/utils.js:120:56)
          at /home/admin/parser/attempt/node_modules/mongodb/lib/cursor.js:745:22
          at handleCallback (/home/admin/parser/attempt/node_modules/mongodb/lib/utils.js:120:56)
          at /home/admin/parser/attempt/node_modules/mongodb/lib/cursor.js:681:20
          at nextFunction (/home/admin/parser/attempt/node_modules/mongodb-core/lib/cursor.js:521:12)
          at /home/admin/parser/attempt/node_modules/mongodb-core/lib/cursor.js:593:7
          at queryCallback (/home/admin/parser/attempt/node_modules/mongodb-core/lib/cursor.js:232:18)
          at handleOperationCallback (/home/admin/parser/attempt/node_modules/mongodb-core/lib/connection/pool.js:474:7)
          at /home/admin/parser/attempt/node_modules/mongodb-core/lib/connection/pool.js:504:9
      ---------------------------------------------
          at handleCallback (/home/admin/parser/attempt/node_modules/mongodb/lib/utils.js:123:13)
          at /home/admin/parser/attempt/node_modules/mongodb/lib/cursor.js:745:22
          at handleCallback (/home/admin/parser/attempt/node_modules/mongodb/lib/utils.js:120:56)
          at /home/admin/parser/attempt/node_modules/mongodb/lib/cursor.js:681:20
          at nextFunction (/home/admin/parser/attempt/node_modules/mongodb-core/lib/cursor.js:521:12)
          at /home/admin/parser/attempt/node_modules/mongodb-core/lib/cursor.js:593:7
          at queryCallback (/home/admin/parser/attempt/node_modules/mongodb-core/lib/cursor.js:232:18)
          at handleOperationCallback (/home/admin/parser/attempt/node_modules/mongodb-core/lib/connection/pool.js:474:7)
          at /home/admin/parser/attempt/node_modules/mongodb-core/lib/connection/pool.js:504:9
      admin@ip-172-33-1-249:~/parser/attempt$ vi node_modules/mongodb/lib/utils.js
      

      The task consists of a Promise.all([]) containing async function calls containing awaited queries (using async/await keywords)... So I am not using any callbacks, only promises.
      I am quite confused as the same task sometimes succeeds and sometime fails for no apparent reason.

      Because of the error message, I have tried wrapping the line triggering the error with a if (typeof callback === 'function') but I still get the same error!!

          if(callback && typeof callback === 'function') {
            return value2 ? callback(err, value1, value2) :  callback(err, value1);
          }
      

      Server-side, the last message I have is the following:

      [conn1225] AssertionException handling request, closing client connection: 6 socket exception [SEND_ERROR] for 127.0.0.1:34316
      

      Note that if I separate my big 1000 queries call into smaller batches, it fixes the issue.

            Assignee:
            matt.broadstone@mongodb.com Matt Broadstone
            Reporter:
            pimpreneil Pimpreneil
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: