Getting MongooseError: Operation `todos.insertOne()` buffering timed out after 10000ms error message
See original GitHub issueThis is the test,
describe("POST /todos", () => {
describe("Todos", () => {
test("return created todo", async () => {
const _data = {
_id,
created,
status: "pending",
subtasks: [],
title: "Todo X"
};
Mockingoose(Todo).toReturn(_data, "save");
const body = { title: "Todo X" };
const data = await Todo.create(body);
expect(data).toMatchObject(_data);
}, 15000);
});
});
The code I am trying to test,
const data = await Todo.create({
title: req.body.title
});
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:8 (1 by maintainers)
Top Results From Across the Web
MongooseError: Operation `users.insertOne()` buffering timed ...
But recently I am making a simple todo app and I face this error when creating a user. ... insertOne()` buffering timed out...
Read more >MongooseError: Operation `users.insertOne()` buffering timed ...
This error can be caused by typos in user properties. (I was trying to set "Email" instead of what was defined on my...
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 >Mongoose error : buffering timed out after 10000ms #9732
Hello, i got this error on mongoose with nodejs : version of mongoose : 5.11.8 I'm trying to save data on my mongodb...
Read more >operation `users.insertone()` buffering timed out after 10000ms
mongooseerror : operation `users.insertone()` buffering timed out after 10000ms. Add Answer | View In TPC Matrix. Technical Problem Cluster First Answered On ......
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 all,
starting from 6.x the authors of mongoose decided to shadow the original
save
function withModel.prototype.$save = Model.prototype.save;
,see https://github.com/Automattic/mongoose/compare/5.x…master#diff-305dbcc98ad8fc959dd0c0be51280893962af34c2d8b18abc871cffc2d80c5f9R521 so that mockingsave
does not work anymore. Modifying the index.js code to include$save
for the ops enumerationand extending
and in line 243:
let all tests pass with 5.x and 6.x. May be @alonronin you may change the code to make it work with both versions. Sadly I am stuck to mocha and sinon and searched for a way to depict the functionality of this great project to our needs/libs, so i am not able to provide a pull request.
Btw: @alonronin: The solution provided in https://github.com/alonronin/mockingoose/issues/77#issuecomment-937651045 is imho not correct, it simply infiltrates the original behaviour with a non-sense mock, so that a spied call with a correctly mocked result of the original function is not guaranteed.
Greetings and hope it helps.
Olli
I am getting the same error after upgrading to
mongoose@^6.0.0
. On 5.x your test should work.