products.deleteMany()` buffering timed out after 10000ms
See original GitHub issueHi i am trying to upload my products from my json file to the database. I am able to connect to the database however when i try to upload the products i am getting this error.
Error with data import MongooseError: Operation `products.deleteMany()` buffering timed out after 10000ms
at Timeout.<anonymous> (C:\Users\nmajo\OneDrive\Desktop\Webapp2\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:185:20)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Webapp2@1.0.0 data:import: `node backend/DBScript.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Webapp2@1.0.0 data:import script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\nmajo\AppData\Roaming\npm-cache\_logs\2021-01-21T23_53_15_306Z-debug.log
This is the code i am using.
require("dotenv").config();
const productData = require("./data/products");
const connectDB = require("./config/database");
const Product = require("./models/Products");
connectDB();
const importData = async () => {
try {
await Product.deleteMany({});
await Product.insertMany(productData);
console.log("Data Import Success");
process.exit();
} catch (error) {
console.error("Error with data import", error);
process.exit(1);
}
};
importData();
When i remove the await on the Product.deleteMany and the Insert many, its saying products have been uploaded, however when i check the mongo db, there are no products. Does anyone have an idea on how i can fix this ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Operation `orders.deleteMany()` buffering timed out after ...
I don't know why showing buffering timed out . MongooseError: Operation `orders.deleteMany()` buffering timed out after 10000ms. seeder.js.
Read more >How to Fix "Buffering timed out after 10000ms" Error in ...
The buffering timeout is usually due to either registering models on a newly created connection but using mongoose.connect() : const mongoose = ...
Read more >MongooseError: Operation `users.insertOne()` buffering timed ...
MongooseError: Operation `users.insertOne()` buffering timed out after 10000ms ... I'm new to MERN stack. I built some MERN app where I didn't ...
Read more >Operation `orders.deleteMany()` buffering timed out after ...
Coding example for the question MongooseError: Operation `orders.deleteMany()` buffering timed out after 10000ms-mongodb.
Read more >Mongoose error : buffering timed out after 10000ms - YouTube
Mongoose error : buffering timed out after 10000ms. 3.5K views 6 months ago. Veera's CodeLab. Veera's CodeLab. 9 subscribers. Subscribe.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi I also have a similar issue and nothing has worked for me so far (users.findOne in my case). One thing that I noticed is that when I search “buffering timed out after 10000ms” in stackoverflow pretty much all of the problems with the above phrasing came from December 2020 and January 2021 (also Feb 2021). So perhaps this is a mongoose problem caused by an update within that time period?
Seconded w/ @TerraAtgithub . I tried to deploy to Heroku many times yesterday but I kept encountering a buffering .find() 10000ms. Even when I’ve wrapped my mongoose.connect inside an async/await function I received a “Error: MongooseError: Cannot call posts.find() before initial connection is complete if bufferCommands = false. Make sure you await mongoose.connect() if you have bufferCommands = false.”
Have noticed few posts recently about the mongoose.connect buffering 10000ms issue within the past few months.