Automattic / mongoose

MongoDB object modeling designed to work in an asynchronous environment.
https://mongoosejs.com
MIT License
26.92k stars 3.84k forks source link

MongooseError: Operation `.deleteOne()` and `.deleteMany()` buffering timed out after 10000ms #10936

Closed comicallybad closed 2 years ago

comicallybad commented 2 years ago

Do you want to request a feature or report a bug? Bug

What is the current behavior? Getting MongooseError timeout errors. I have not changed my code, or updated anything and I keep getting this timeout error. I exported my database and ran the same master branch with the same database on another PC and I do not get the error.

If the current behavior is a bug, please provide the steps to reproduce.

const mongoose = require("mongoose");
const { dbSetup } = require("../../dbFunctions.js");

module.exports = client => {
    var time = new Date();
    console.log(time.toLocaleString('en-US', { month: 'numeric', day: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', hour12: true }));  

    global.activities = [`${client.guilds.cache.size} servers!`, `${client.channels.cache.size} channels!`, `${client.users.cache.size} users!`], i = 0;
    setInterval(() => client.user.setActivity(`${prefix}help | ${activities[i++ % activities.length]}`, { type: "PLAYING" }), 7500)

    mongoose.connect("mongodb://localhost/ComicallyBOT2", { useUnifiedTopology: true, useNewUrlParser: true }).then(console.log("Successfully connected to Mongodb"));

    dbSetup(client);

    client.music.init(client.user.id);
}

What is the expected behavior? Simple connection to mongodb, with the console log of "Successfully connected to MongoDB"

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version. v16.13.0 node.js, v5.13.12 MongoDB Community Server 5.0.3 (current)

Error:

MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\...\...\...\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\...\...\...\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\...\...\...\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\...\...\...\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\...\...\...\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\...\...\...\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)
10/26/2021, 12:11:57 AM
Successfully connected to Mongodb
Successfully connected to Erela
IslandRhythms commented 2 years ago

Your mongoose operations are executing before you are connected to the db. Modify your code so that the connection happens first.

comicallybad commented 2 years ago

Your mongoose operations are executing before you are connected to the db. Modify your code so that the connection happens first.

False. Not calling any mongoose functions besides connect until my bot is online. I can comment out all code besides mongoose.connect and it still is throwing the same error.

comicallybad commented 2 years ago

The only time I even use the method .deleteMany() is in a clean database command. Not like I am calling that command before my bot starts

IslandRhythms commented 2 years ago

put the last two lines inside of the .then() and tell me what happens

comicallybad commented 2 years ago

put the last two lines inside of the .then() and tell me what happens

I did. But doesn’t matter either way as dbsetup doesn’t call either of those methods.


dbSetup: async function (client) {
        let guildsID = await client.guilds.cache.map(guild => guild.id);
        let guildsName = await client.guilds.cache.map(guild => guild.name);
        let commands = await client.commands.map(cmd => cmd.name);

        guildsID.forEach((element, guildIndex) => { //for each guild
            db.findOne({ guildID: guildsID[guildIndex] }, (err, exists) => {
                if (!exists) {
                    const newDB = new db({
                        _id: mongoose.Types.ObjectId(),
                        guildID: guildsID[guildIndex],
                        guildName: guildsName[guildIndex],
                        commands: [],
                        xpSystem: false,
                        xpRoles: [],
                        reactionRoles: [],
                        profanityFilter: false,
                        antiSpam: false,
                        badWordList: [],
                        xpMultiplier: 1,
                    })
                    newDB.save().catch(err => console.log(err));
                } else {
                    exists.guildName = guildsName[guildIndex]; //in case name changed
                    exists.save().catch(err => console.log(err));
                }
            }).then(() => {
                commands.forEach((element, cmdIndex) => {
                    db.findOne({
                        guildID: guildsID[guildIndex],
                        commands: { $elemMatch: { name: commands[cmdIndex] } }
                    }, (err, exists) => {
                        if (!exists) {
                            db.updateOne({ guildID: guildsID[guildIndex] }, {
                                $push: { commands: { name: commands[cmdIndex], status: true } }
                            }).catch(err => console.log(err));
                        }
                    })
                });
            }).catch(err => console.log(err));
        });
    },
comicallybad commented 2 years ago

put the last two lines inside of the .then() and tell me what happens

I commented out all code, and just running mongoose.connect() I get the errors. I checked the documentation and it mentioned considering doing a mongoose.set(), I forgot what the value was, but it was like bufferCommands, false, but when I tried that it did not work either. Like I said, this same code and database is running on another computer with the same version of node, mongo and mongoose, and I am not getting any timeout Errors.

rgolea commented 2 years ago

@comicallybad have you upgraded to MacOS Monterey? This has happened to me since the upgrade. Same code a while back did not have any issues.

I'm looking into reinstalling mongodb and reinstalling all node_modules dependencies. I'll tell you if I find something.

Also it seems #10940 and maybe #10941 might be related to this same behaviour.

rgolea commented 2 years ago

After updating brew and reinstalling all dependencies, I finally managed to make it work. In any case, I saw that you're not using node v17.x. I wouldn't try to use it just now. I've found several deprecations that made my repo not work either on webpack or on different compilers.

Hope it helps @comicallybad

comicallybad commented 2 years ago

@rgolea I am running on windows. I am running the same node version on my server and testing pc. I am not getting any errors on my pc with the same versions of node, mongoose, and mongodb community. So not sure what's causing it to timeout on the server PC but not mine, I can't replicate it if I try.

comicallybad commented 2 years ago

I completely uninstalled node, mongodb, and mongodb compass. I went and found every residual file possible and deleted it. I even changed my code, although I knew it wouldn't make a difference as the .connet() method alone is what's causing the errors. But even with this new code I am still getting the same exact timeout issues. Nowhere am I calling these functions beforehand. This is literally where I connect to mongodb:

const mongoose = require("mongoose");
const { dbSetup } = require("../../dbFunctions.js");

module.exports = client => {
    var time = new Date();
    console.log(time.toLocaleString('en-US', { month: 'numeric', day: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', hour12: true }));

    global.activities = [`${client.guilds.cache.size} servers!`, `${client.channels.cache.size} channels!`, `${client.users.cache.size} users!`], i = 0;
    setInterval(() => client.user.setActivity(`${prefix}help | ${activities[i++ % activities.length]}`, { type: "PLAYING" }), 7500)

    mongoose.connect("mongodb://localhost/ComicallyBOT2", { useUnifiedTopology: true, useNewUrlParser: true }).then(() => {
        console.log("Successfully connected to Mongodb");
        dbSetup(client);
    });

    client.music.init(client.user.id);
}

Once again, I am on the SAME node version, SAME mongoose version, SAME mongodb compass version even. However, I am not able to replicate this on my machine with the same code. The same exact data transferred over. I can't figure it out. I am not sure if it literally is the server is too slow or something? But I don't know what else to do at this point besides a complete factory reset of windows and try to see if that fixes it, but I already deleted everything and reinstalled it all to get the same error. I was not getting this error just 2 weeks ago. This just randomly started to happen.

rgolea commented 2 years ago

As far as I can see, the code is right. If this is exactly your code, check the port maybe, otherwise, try and connect to a remote mongo database and see if the error persists.

IslandRhythms commented 2 years ago

try removing useUnifiedTopology and useNewUrlParser, worked with someone in the past. Also, have you tried just connecting to localhost on standalone to see if you can even do that?

const mongoose = require('mongoose');

async function test() {
    await mongoose.connect('mongodb://localhost:27017/', {useNewUrlParser: true,
    useUnifiedTopology: true,});
}

mongoose.connection.on('open', () => {
    console.log('open fire');
});

mongoose.connection.on('connected', () => {
    console.log('connected successfully');
});

test();
comicallybad commented 2 years ago

try removing useUnifiedTopology and useNewUrlParser, worked with someone in the past. Also, have you tried just connecting to localhost on standalone to see if you can even do that?

const mongoose = require('mongoose');

async function test() {
    await mongoose.connect('mongodb://localhost:27017/', {useNewUrlParser: true,
    useUnifiedTopology: true,});
}

mongoose.connection.on('open', () => {
    console.log('open fire');
});

mongoose.connection.on('connected', () => {
    console.log('connected successfully');
});

test();

With this code I got this error log:

 MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
11/3/2021, 8:33:22 PM
connected successfully
open fire
Successfully connected to Erela

Without the useUnifiedTopology and uewNewURLParser:

    async function test() {
        await mongoose.connect('mongodb://localhost:27017/');
    }

    mongoose.connection.on('open', () => {
        console.log('open fire');
    });

    mongoose.connection.on('connected', () => {
        console.log('connected successfully');
    });

    test();

I got this log:

MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
11/3/2021, 8:35:30 PM
(node:6228) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:6228) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
connected successfully
open fire
Successfully connected to Erela

Note: I also did check for any port confliction, and I do not have any other applications using that port. I mean it is literally almost a blank windows installation with node, mongo, my bot, and a few other applications like iobit defrag.

IslandRhythms commented 2 years ago

You ran that it a separate workspace?

comicallybad commented 2 years ago

You ran that it a separate workspace?

No same workspace. I did also run it on my other workspace, my testing pc, and didn’t get any errors, but I’m not getting any errors with the original code either on my testing pc.

IslandRhythms commented 2 years ago

can you provide where the bot starts up from?

comicallybad commented 2 years ago

https://github.com/comicallybad/ComicallyBot2.0 The bot starts its shard manager from index.js. Then the bot starts in client.js. So client.on ready event (in my events folder) is where I have this code for connecting to mongodb

IslandRhythms commented 2 years ago

try 127.0.0.1 instead of locahost

comicallybad commented 2 years ago

Still connects to mongo fine, same timeout errors though.

IslandRhythms commented 2 years ago

Add these events in where your connection line is and see if they provide any usefule information

    mongoose.connection.on('error', (err) => {
        console.log('Error', err);
    });
    mongoose.connection.on('reconnected', (data) => {
        console.log('reconnected', data);
    });
mongoose.connection.on('disconnected',  () => {
console.log('disconnected');
});
mongoose.connection.on('disconnecting',  () => {
console.log('disconnecting');
});
mongoose.connection.on('close',  () => {
console.log('close');
});
    mongoose.connection.on('reconnectFailed', () => {
        console.log('reconnect failed');
    });
    mongoose.connection.on('reconnectTries', (data) => {
        console.log('attempts', data);
    });
comicallybad commented 2 years ago

I'll give this a try for a day or two. On startup no errors except the same timeout errors. So I will leave it running and see if I do get any errors.

comicallybad commented 2 years ago

Been 3 days, and the bot has not gone offline once, and no further errors logged. I think at this point I am going to probably just factory reset the computer and reinstall everything and clone the repo to see if that works. Or just upgrade my server. I think honestly it could just be how slow it is running. I can't replicate it on my mac, my pc, with the same versions of everything, same cloned database. So it must just be the server just being too slow. When I run the start.bat command, my bot will go online within 3 seconds on my mac or pc. With the server, it'll take quite awhile to launch the shard, then it will take a while to load the commands, and then I get the timeout errors before it either finally goes online or it errors because the shard wasn't ready to be spawned.

vkarpov15 commented 2 years ago

Based on your "With the server, it'll take quite awhile to launch the shard" comment and your debug output, it looks like you're starting MongoDB after your process is already running. The output you're seeing is expected if you execute several deleteOne() and deleteMany() commands before your MongoDB server is fully started, and then the MongoDB server finally starts up and Mongoose successfully connects. Does that help @comicallybad ?

comicallybad commented 2 years ago

I am getting the error now too on my testing PC. I never am calling those methods before the bot goes online. The only time deleteOne or deleteMany are made are when a user joins or leaves the server, which cannot occur until the bot is successfully connected online. So I still am not sure what's causing this issue, it's really annoying.

khairnarsaurabh23 commented 2 years ago

@comicallybad I think you have forgotten to mention port 27017 in connection url. It must be "mongodb://localhost:27017/xxxxx" like this.

comicallybad commented 2 years ago

@comicallybad I think you have forgotten to mention port 27017 in connection url. It must be "mongodb://localhost:27017/xxxxx" like this.

try removing useUnifiedTopology and useNewUrlParser, worked with someone in the past. Also, have you tried just connecting to localhost on standalone to see if you can even do that?

const mongoose = require('mongoose');

async function test() {
    await mongoose.connect('mongodb://localhost:27017/', {useNewUrlParser: true,
    useUnifiedTopology: true,});
}

mongoose.connection.on('open', () => {
    console.log('open fire');
});

mongoose.connection.on('connected', () => {
    console.log('connected successfully');
});

test();

With this code I got this error log:

 MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
11/3/2021, 8:33:22 PM
connected successfully
open fire
Successfully connected to Erela

Without the useUnifiedTopology and uewNewURLParser:

    async function test() {
        await mongoose.connect('mongodb://localhost:27017/');
    }

    mongoose.connection.on('open', () => {
        console.log('open fire');
    });

    mongoose.connection.on('connected', () => {
        console.log('connected successfully');
    });

    test();

I got this log:

MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `dbs.deleteOne()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
MongooseError: Operation `xps.deleteMany()` buffering timed out after 10000ms
    at Timeout.<anonymous> (C:\Users\amp56\Documents\Projects\Comicallybot2.0\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:198:23)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
11/3/2021, 8:35:30 PM
(node:6228) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:6228) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
connected successfully
open fire
Successfully connected to Erela

Note: I also did check for any port confliction, and I do not have any other applications using that port. I mean it is literally almost a blank windows installation with node, mongo, my bot, and a few other applications like iobit defrag.

@khairnarsaurabh23 been there done that

vkarpov15 commented 2 years ago

@comicallybad is your MongoDB server consistently running when you're starting up your bot?

comicallybad commented 2 years ago

@vkarpov15 yeah it connects fine each time it just has those errors on startup before connecting each time.

vkarpov15 commented 2 years ago

Ok. Are you waiting for mongoose.connect() before calling xps.deleteMany(), etc.?

comicallybad commented 2 years ago

@vkarpov15 i don’t even call those functions. I have a command that does, yes. But I can’t even call those commands until the bot is online. So I have no idea why it’s even making any database calls. I call my dbsetup function after mongoose connects.

comicallybad commented 2 years ago

And again, I can’t replicate this on my other computers. Doesn’t replicate on my Mac or gaming pc. Only my server does this happen and I’ve tried everything. Reinstalling everything. Making sure I have the same version of everything I do on my gaming pc. Still have the issue on the server but not my laptop or pc.

vkarpov15 commented 2 years ago

@comicallybad so you don't call mongoose.connect()? That might explain why you're seeing this error message: if you don't connect to the db, Mongoose will error out.

comicallybad commented 2 years ago

@vkarpov15 yes.. I am connecting? and we have established that the use of having a port in the connection did not make a difference. Sorry I thought in your comment you said the .deleteOne() and .deleteMany() methods, not .connect()

const mongoose = require("mongoose");
const { dbSetup } = require("../../dbFunctions.js");

module.exports = client => {
    var time = new Date();
    console.log(time.toLocaleString('en-US', { month: 'numeric', day: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', hour12: true }));

    global.activities = [`${client.guilds.cache.size} servers!`, `${client.channels.cache.size} channels!`, `${client.users.cache.size} users!`], i = 0;
    setInterval(() => client.user.setActivity(`${prefix}help | ${activities[i++ % activities.length]}`, { type: "PLAYING" }), 7500)

    mongoose.connect("mongodb://localhost/ComicallyBOT2", { useUnifiedTopology: true, useNewUrlParser: true }).then(() => {
        console.log("Successfully connected to Mongodb");
        dbSetup(client);
    });

    client.music.init(client.user.id);
}
IslandRhythms commented 2 years ago

I think the problem at its core is that you're connecting to mongodb late. Move your connection code to whereever you login with your bot token.

vkarpov15 commented 2 years ago

Try using await mongoose.connect() before all of your async operations in dbSetup(), instead of calling mongoose.connect() outside of dbSetup? Also, why are you mixing callbacks and async/await in this comment?

comicallybad commented 2 years ago

Well after changing nothing, I haven’t had this error in weeks now. I’m not sure if I updated a package like discord.js and that fixed something. I’m not sure if I just finally removed some duplicate file or something but it’s no longer happening. I was getting it to replicate on multiple machines before and now, nothing. So I guess it’s a mystery I will never understand 😂

btdjangbah001 commented 2 years ago

Well after changing nothing, I haven’t had this error in weeks now. I’m not sure if I updated a package like discord.js and that fixed something. I’m not sure if I just finally removed some duplicate file or something but it’s no longer happening. I was getting it to replicate on multiple machines before and now, nothing. So I guess it’s a mystery I will never understand 😂

I am facing the same issues now 😪

vkarpov15 commented 2 years ago

@btdjangbah001 please open a new issue and follow the issue template