Androz2091 / discord-giveaways

🎉 Complete framework to facilitate the creation of giveaways using discord.js
https://discord-giveaways.js.org
MIT License
334 stars 127 forks source link

Mongoose/MongoDB does not connect properly | Buffering timed out #198

Closed Dragonizedpizza closed 3 years ago

Dragonizedpizza commented 3 years ago

Hi, whenever a user deletes the giveaway message, my console gets spammed. It gets spammed with Discord API errors saying unknown message. This would continue until the giveaway time has finished. Any idea how to stop this?

Dragonizedpizza commented 3 years ago

also, when I try to use the Mongoose.js example in the develop branch, I get this error: MongooseError: Operation giveaways.insertOne() buffering timed out after 10000ms

Nico105 commented 3 years ago

Hi, whenever a user deletes the giveaway message, my console gets spammed. It gets spammed with Discord API errors saying unknown message. This would continue until the giveaway time has finished. Any idea how to stop this?

npm i Androz2091/discord-giveaways#develop should have the fix, will get released with the next version

Dragonizedpizza commented 3 years ago

also, when I try to use the Mongoose.js example in the develop branch, I get this error: MongooseError: Operation giveaways.insertOne() buffering timed out after 10000ms

What about this?

Nico105 commented 3 years ago

https://github.com/Automattic/mongoose/issues/9732 Look through this

Dragonizedpizza commented 3 years ago

@Nico105 none worked

Nico105 commented 3 years ago

Which line does even cause this error? Because in the example .insertOne() does not get used. The error in the code of the "mongoose" package right?

Dragonizedpizza commented 3 years ago

I'll send both the errors. (node:20788) UnhandledPromiseRejectionWarning: MongooseError: Operation `giveaways.insertOne()` buffering timed out after 10000ms at Timeout.<anonymous> (C:\Users\akyra\Desktop\Bots\DragonNight\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:20) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7) (Use `node --trace-warnings ...` to show where the warning was created) (node:20788) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:20788) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

(node:20788) UnhandledPromiseRejectionWarning: MongooseError: Operation `giveaways.findOneAndUpdate()` buffering timed out after 10000ms at Timeout.<anonymous> (C:\Users\akyra\Desktop\Bots\DragonNight\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:20) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7) (node:20788) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

Dragonizedpizza commented 3 years ago

Which line does even cause this error? Because in the example .insertOne() does not get used. The error in the code of the "mongoose" package right?

@Nico105 yes I think

Nico105 commented 3 years ago

mongoose.connect(config.mongouri, { useFindAndModify: false }); is it still there if you use the connect method without your custom options?

Dragonizedpizza commented 3 years ago

@Nico105 I connect through this: mongoose.connect(config.mongouri, { useNewUrlParser: true, useUnifiedTopology: true, useFindAndModify: false, });

Nico105 commented 3 years ago

As said try it with the default (my) one

Dragonizedpizza commented 3 years ago

(node:24544) UnhandledPromiseRejectionWarning: MongooseError: Operation `giveaways.insertOne()` buffering timed out after 10000ms at Timeout.<anonymous> (C:\Users\akyra\Desktop\Bots\DragonNight\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:20) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7) (node:24544) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:24544) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Dragonizedpizza commented 3 years ago

@Nico105 same error.

Nico105 commented 3 years ago

.catch(error => console.error(error)); add this after .connect() and btw are you sure the IP you're connecting from is whitelisted?

Dragonizedpizza commented 3 years ago

I switched on allow connections from everywhere @Nico105...

Nico105 commented 3 years ago

"was resolved by removing the node_module folder, *.json (=package) files and reinstalling the mongoose module." https://www.codegrepper.com/code-examples/csharp/MongooseError%3A+Operation+%60warns.findOne%28%29%60+buffering+timed+out+after+10000ms

Dragonizedpizza commented 3 years ago

@Nico105 I don't have a folder with the text .json in it lmao

Nico105 commented 3 years ago

That's not the folder, the package.lock.json is a file The folder is "node_modules" if you misread that Delete both then run npm i

Dragonizedpizza commented 3 years ago

the instructions aren't very clear but ok

Nico105 commented 3 years ago
  1. Delete package.lock.json file
  2. Delete node_modules folder
  3. npm i

You could be glad I'm even trying to help because this is not a issue of discord-giveaways in the first place...

Dragonizedpizza commented 3 years ago

yes yes, I am very grateful :)

Dragonizedpizza commented 3 years ago

Operation `giveaways.insertOne()` buffering timed out after 10000ms

Dragonizedpizza commented 3 years ago

@Nico105 didn't work ):

Dragonizedpizza commented 3 years ago
  1. Delete package.lock.json file
  2. Delete node_modules folder
  3. npm i

You could be glad I'm even trying to help because this is not a issue of discord-giveaways in the first place...

Also, it kinda is cos the examples in the discord-giveaways package is invalid.

Nico105 commented 3 years ago
  1. Delete package.lock.json file
  2. Delete node_modules folder
  3. npm i

You could be glad I'm even trying to help because this is not a issue of discord-giveaways in the first place...

Also, it kinda is cos the examples in the discord-giveaways package is invalid.

Wrong, the example code is 100% valid and functioning, what is wrong here are just mongoDB/mongoose connection/network/setting issues, discord-giveaways is not the fault of this, the error clearly said that it was in the mongoose folder and from what i found about "buffering", what it says in your error, is that you pretty much can "use" mongoose things before you connected to the actual DB but only for a certain time => "timeout after 10000ms", because it couldn't connect even after the buffer time. It is not the example codes fault, for enough people it just worked fine first try. As said it has smth to do with mongoDB configuration/access/perms or smth Don't expect that we can "magically" change smth in the example code and make it work for you. Things just don't work the same on different PC's on different networks, on differents settings/configuration It would't even have gotten merged into the develop branch if it wouldn't have functioned.

Dragonizedpizza commented 3 years ago

Uh- Ok then-

Dragonizedpizza commented 3 years ago

do I still get help?

Nico105 commented 3 years ago

If someone knows a solution and sees this, then such a person will very likely tell it to you, but because this is just a discord.js giveaway module not too many know-solution persons will see this, so you should start searching elsewhere for answers, you could maybe make a issue on the github mongoose page or find a discord server or some forum which deals with mongo errors or just ask on stackoverflow. :)

Nico105 commented 3 years ago

Btw what you could try is making a completely new mongoDB project/cluster with all default settings (exept allow all IPs) and connect to that one to test

Dragonizedpizza commented 3 years ago

alright, ty!

MaximKing1 commented 3 years ago

Have you fixed this @Dragonizedpizza ? I have added a connection string below to try I had this error and this fixed for me.

mongoose.connect(process.env.MONGO_DB, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false }); 
Dragonizedpizza commented 3 years ago

@MaximKing1 nope.

Dragonizedpizza commented 3 years ago

Forgot about this.

The problem was that I was using MongoDB's free cluster, which supports only one connection at a time.