Model buffering takes more than 10000ms for `findOne` operation
See original GitHub issueDo you want to request a feature or report a bug?
Possibly a bug.
What is the current behavior?
Buffering takes more than 10000ms and this has an impact on app usage. The error message is Operation wallets.findOne() buffering timed out after 10000ms
.
This error is intermittent (i.e it comes and goes).
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top Results From Across the Web
Operation `users.findOne()` buffering timed out after 10000ms ...
Your model is being called before the connection is established. You need to use async/await with connect() or createConnection(); or use .then ......
Read more >Operation 'x.find()` buffering timed out after 10000ms
This error ate me out for at most 2 days. ... But when I tried to execute the function that uses a find()...
Read more >MongooseError: Operation `users.insertOne()` buffering timed ...
User.find() is a Model.method() call, and it has a timeout. It is timing out probably because you're not connecting to the server, but...
Read more >MongooseError - Operation buffering timed out after 10000ms ...
i also would recommend to either cache the DatasourceModel or only run the function once (the connection does not need to be connected...
Read more >How to Fix "Buffering timed out after 10000ms" Error in ...
Remember that, in Mongoose, every model has exactly one connection to MongoDB. The buffering timeout is usually due to either registering models ......
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
This error message is due to Mongoose thinking it isn’t connected to the database. You can prevent Mongoose from throwing this error by disabling buffering:
mongoose.set('bufferCommands', false)
, see https://mongoosejs.com/docs/guide.html#bufferCommands. However, if the issue is due to issues connecting to MongoDB, you’ll just get a ServerSelectionError instead of a BufferTimeoutError.My recommendation is to disable buffering and see if that helps. If it does, then this is a Mongoose bug and I’ll need some more information to track it down.
@henrispkl please make sure you carefully review our docs on testing with Jest: https://mongoosejs.com/docs/jest.html . Jest is filled with unpredictable footguns, and your code makes it seem like you’re running into one of them: setting up your Mongoose connecting in
globalSetup
I have the same issue, on my local machine works but not on the server. The Mongodb on server has been used by express, but when I run a node script to manage the database directly gives me this error.
It connects, but when I try to do a .find() it gives me the buffer error… Did try everything proposed here with no sucess…
is any previous version working? tested a lot under 5.X but same behaviour, works local but not when runs in the server
Update:
What i’ve found here, if I import the Model from another file/folder, it gives me error!
Solution
I’ve found my problem!!! I had a left over node_modules inside on of the projects folder. So, if u have a similar issue, check if u have just ONE node_modules over your folders!