MongoDB / Node: Incorrect Arguments

MongoDB / Node: Incorrect Arguments

By : user2954938
Date : November 22 2020, 10:33 AM
wish of those help There has unfortunately been a lot of radio silence from the MongoDB team regarding this issue, but I finally happened upon the reason why this error occurs: there was a problem in one of my mongo callbacks, which was (probably) throwing an exception. It seems Mongo caught the error and threw this non-descript error back at me. For the record, the stack trace for the error (posted in a link in the question as well), is as follows:
code :
MongoError: Incorrect arguments
at Object.toError (/home/admin/idlebot/src/modules/idle/node_modules/mongodb/lib/mongodb/utils.js:114:11)
at Server.Base._callHandler (/home/admin/idlebot/src/modules/idle/node_modules/mongodb/lib/mongodb/connection/base.js:455:65)
at /home/admin/idlebot/src/modules/idle/node_modules/mongodb/lib/mongodb/connection/server.js:481:18
at [object Object].MongoReply.parseBody (/home/admin/idlebot/src/modules/idle/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
at [object Object].<anonymous> (/home/admin/idlebot/src/modules/idle/node_modules/mongodb/lib/mongodb/connection/server.js:439:20)
at [object Object].emit (events.js:95:17)
at [object Object].<anonymous> (/home/admin/idlebot/src/modules/idle/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:201:13)
at [object Object].emit (events.js:98:17)
at Socket.<anonymous> (/home/admin/idlebot/src/modules/idle/node_modules/mongodb/lib/mongodb/connection/connection.js:440:22)
at Socket.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:764:14)
at Socket.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:426:10)
at emitReadable (_stream_readable.js:422:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at TCP.onread (net.js:528:21)

Share : facebook icon twitter icon
How can I set up MongoDB on a Node.js server using node-mongodb-native in an EC2 environment?

How can I set up MongoDB on a Node.js server using node-mongodb-native in an EC2 environment?

By : Mahmoud samir
Date : March 29 2020, 07:55 AM
wish help you to fix your issue This was originally posted by the question asker. A mod asked him in the comments to post it as an answer, but got no response. So, I cleaned it up and am posting it myself.
When you look at the code, you will notice that the createServer code is inside db.open. It won't work if you reverse it. Also, do not close the db connection. Otherwise, after the first time, the db connection will not be opened again. (Of course, db.open is declared outside of createServer.) I have no clue why createServer is inside db.open. I guess it may have to do with not opening too many db connections?
code :
$ yum install gcc-c++
$ curl -O http://nodejs.org/dist/node-v0.2.6.tar.gz
$ tar -xzf node-v0.2.6.tar.gz
$ cd nodejs
$ sudo ./configure --without-ssl
$ sudo make
$ sudo make install
$ curl -O http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.6.5.tgz
$ tar -xzf mongodb-linux-x86_64-1.6.5.tgz
$ sudo mkdir /data/db/r01/
$ ./mongodb/bin/mongod --dbpath /data/db/r01/
$ curl -O https://download.github.com/christkv-node-mongodb-native-V0.8.1-91-g54525d8.tar.gz
$ tar -xzf christkv-node-mongodb-native-V0.8.1-91-g54525d8.tar.gz
$ cd node-mongodb-native
$ make
global.inData = '';
var http = require('http');
sys = require("sys");

/* set up DB */

var Db = require('./node-mongodb-native/lib/mongodb').Db,
  Connection = require('./node-mongodb-native/lib/mongodb').Connection,
  Server = require('./node-mongodb-native/lib/mongodb').Server,
  BSON = require('./node-mongodb-native/lib/mongodb').BSONNative;

var host = process.env['MONGO_NODE_DRIVER_HOST'] != null ? process.env['MONGO_NODE_DRIVER_HOST'] : 'localhost';
var port = process.env['MONGO_NODE_DRIVER_PORT'] != null ? process.env['MONGO_NODE_DRIVER_PORT'] : Connection.DEFAULT_PORT;
var db = new Db('test01', new Server(host, port, {}), {native_parser:true});

db.open(function(err, db) { 
    http.createServer(function (req, res) {
        res.writeHead(200, {'Content-Type': 'text/plain'});

        global.inData = {'p':'', 'url':''};

        // get IP address
        var ipAddress = req.connection.remoteAddress;
        global.inData.ip = ipAddress;

        // date time
        var d = new Date();
        var ts = d.valueOf();
        global.inData.ts = ts;

        // get the http query
        var qs = {};
        qs = require('url').parse(req.url, true);
        if (qs.query !== null) {
            for (var key in qs.query) {
                if (key == 'p') {
                    global.inData.p = qs.query[key];
                if (key == 'url') {
                    global.inData.url = qs.query[key];

        if (global.inData.p == '' && global.inData.url == '') {
        } else {
            db.collection('clickCount', function(err, collection) { 
                if (err) {
                    console.log('is error \n' + err);

                //db.close();  // DO NOT CLOSE THE CONNECTION

console.log('Server running at whatever host :8080');
Unsure How To Interpret the MongoDB node.js' Driver Callback Arguments For collection.insert

Unsure How To Interpret the MongoDB node.js' Driver Callback Arguments For collection.insert

By : user2603720
Date : March 29 2020, 07:55 AM
hope this fix your issue Think about it this way: Err can only be either null or an instance of a JavaScript Error object. A "partial success" implies that at least one error has occurred and so the method would return an Error, which you would need to handle in your callback. The 'message' property of the Error will usually tell you what you need to know.
In my experience, most documentation for node.js libraries is vague (and, sometimes, non-existent). Reading the source or even simply printing results to the console is pretty much necessary during development.
Get the MongoDB server version from node-mongodb-native in node.js

Get the MongoDB server version from node-mongodb-native in node.js

By : Mukul Bhasin
Date : March 29 2020, 07:55 AM
this will help You have to use the serverStatus database command to retrieve the version of the mongod or mongos instance you're connected to.
The native node.js driver provides the Admin.serverStatus for that purpose:
code :
var MongoClient = require('mongodb').MongoClient
var url = 'mongodb://localhost:27017/test'
var conn = MongoClient.connect(url, function(err, db) {
    var adminDb = db.admin();
    adminDb.serverStatus(function(err, info) {
Mongodb aggregate run in terminal but when run in node.js with mongoose it's return "APIError: Arguments must be ag

Mongodb aggregate run in terminal but when run in node.js with mongoose it's return "APIError: Arguments must be ag

By : kevin-8z
Date : March 29 2020, 07:55 AM
Hope this helps When I run the aggregate in the mongo throw terminal it returns the correct data, but when I run the same aggregate in the code it returns an error. , will this worked with me
code :
async function search(req, res) {
  try {
    const customers = await Customer.aggregate([
        $match: {
          gender: 'male'
    customers.get(function(err, ress){
      if (ress) {
      } else {

  } catch(e) {
    res.status(httpStatus.INTERNAL_SERVER_ERROR) .json(Response.failure(e));

Uncaught, unspecified "error" event. (Incorrect arguments) in passport [Node.js]

Uncaught, unspecified "error" event. (Incorrect arguments) in passport [Node.js]

By : Umer Mirza
Date : March 29 2020, 07:55 AM
like below fixes the issue I received the same error when using Passport with Bcrypt [bcrypt-nodejs].
In my user model I had
Related Posts Related Posts :
  • how do I return data from a node.js request call? (undefined is not a function)
  • res.sendfile() doesn't serve javascripts well
  • File path completion relative to the current file directory
  • Tuning node-mongodb-native connection pool size
  • Express Socket.io example server not working
  • node js can't install right on my Ubuntu computer
  • How can i do an "or" query in a Model.find on Sails?
  • Confused in starting a project in node.js with npm install
  • unit testing express route with async callback
  • Mongoose sum operation in collection
  • document save function not working in mongoose
  • Why is the zlib inflate function is not working in correct order in node.js?
  • Nested if inside each (Handlebars template in Express app)
  • How does the cookie-session middleware work in expressjs?
  • grunt-processhtml remove not working when specifying a target
  • Error: CERT_HAS_EXPIRED in Node.js request module (macu vs facebook)
  • Async web requests are making 'socket hangup' in node.js
  • ExpressJS: Middleware control flow for Router.param() & Router.use()
  • Glob recursive/zero or more directories, excluding directories
  • node.js v0.11.14 as service with --harmony
  • Running npm install from Sublime Text 2 doesn't work
  • update on a subdoc with mongoose
  • NodeJS Aerospike UDF execute memory leak
  • Alternative to path module that always uses forward-slashes?
  • How do you stream a csv file into a node web app?
  • How to modularize routing with Node.js Express
  • NodeJS - Modularising SQLite3
  • How to use Aggregate in mongoose
  • How to generate multiple reports with mocha?
  • AWS Lambda making video thumbnails
  • MEAN stack on Ubuntu 14.04 suddenly stopped working
  • node.js/express/mongoose noob issue
  • Nodejs ssh convert output byte stream to a sliceable string
  • different behavior of process.argv
  • How to expose the Application model's register method
  • How to install FFMPEG on Node/Meteor server?
  • How Can I Use vhost to Redirect a Sub-Domain to an ExpressJS Route?
  • Gmail API not respecting UTF encoding in subject
  • installing Node modules on Docker: why are they disappearing?
  • How do I set up Node/Express to act as a STUN server?
  • What is the Linear Execution Model in Meteor?
  • connect-redis and express-session results in req.session undefined
  • Application Error Heroku - Problems with Deployment
  • How to pass node v8 args and script args to pm2?
  • Can it be necessary to require a module (child_process in this case) more than once?
  • Too many bad command: outbound emails with Haraka
  • what does require("child_process") actually do?
  • How can I list all my Amazon EC2 instances using Node.js in AWS Lambda?
  • Passing param to custom middleware
  • How do I debug "Error: spawn ENOENT" on node.js?
  • Proper way to combine route and api auth using loopback.js
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org