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

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

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 38 (1 by maintainers)

Most upvoted comments

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