Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

508
Views
MongooseError: Query was already executed

I updated Mongoose to the latest version (6.0.1) and now I'm getting this error whenever .findOne() is executed:

MongooseError: Query was already executed: Streams.findOne({ i: 6 })
    at model.Query._wrappedThunk [as _findOne] (C:\Users\honza\ZiggerTestMaster\node_modules\mongoose\lib\helpers\query\wrapThunk.js:21:19)
    at C:\Users\honza\ZiggerTestMaster\node_modules\kareem\index.js:370:33
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
    at runNextTicks (node:internal/process/task_queues:65:3)
    at listOnTimeout (node:internal/timers:526:9)
    at processTimers (node:internal/timers:500:7) {
  originalStack: 'Error\n' +
    '    at model.Query._wrappedThunk [as _findOne] (C:\\Users\\honza\\ZiggerTestMaster\\node_modules\\mongoose\\lib\\helpers\\query\\wrapThunk.js:25:28)\n' +
    '    at C:\\Users\\honza\\ZiggerTestMaster\\node_modules\\kareem\\index.js:370:33\n' +
    '    at processTicksAndRejections (node:internal/process/task_queues:78:11)\n' +
    '    at runNextTicks (node:internal/process/task_queues:65:3)\n' +
    '    at listOnTimeout (node:internal/timers:526:9)\n' +
    '    at processTimers (node:internal/timers:500:7)'
}

My code is as follows:

var visitorData = Visitor.find({});
    
app.get("/retrieve", function(req,res){
    visitorData.exec(function (err,data) {
        if (err) {
            throw err;
        }
        res.render("retrieve", { title:"View Visitor Data", records: data});
     });
});

It executes properly the first time I open the route but, whenever I refresh it, it throws the above error. Has been happening since Mongoose got the latest version.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!