NicolasF
NicolasF

Reputation: 35

How to debug mongoerror?

This is probably a straightforward question. If so, please excuse me.

I'm doing axios requests to nuxt, which does mongoose requests. For example, I have this function here:

  let aggregation = [
    {$unwind: {path:"$versions"}}, 
    {$match: {}},
    {$group: {
      _id:    "$_id",
      versions: {$push: 
        {nlp : "$versions.nlp"}
      }
    } }
  ]
  scraps = await Scraps.aggregate(aggregation);

However, I keep having this sort of errors:

{"ok":0,"code":16945,"codeName":"Location16945","name":"MongoError"}
Request failed with status code 500

  at createError (node_modules\axios\lib\core\createError.js:16:15)
  at settle (node_modules\axios\lib\core\settle.js:17:12)
  at IncomingMessage.handleStreamEnd (node_modules\axios\lib\adapters\http.js:236:11)
  at IncomingMessage.emit (events.js:327:22)
  at IncomingMessage.EventEmitter.emit (domain.js:482:12)
  at endReadableNT (_stream_readable.js:1221:12)
  at processTicksAndRejections (internal/process/task_queues.js:84:21) 

I don't know what is causing this bug, as the error is not explicit to me.

My question: beyond this very specific example, do you have an idea, a method, or a tool, to provide a comprehensive explanation and/or to debug such errors?

Thanks!

Upvotes: 1

Views: 455

Answers (1)

Gibbs
Gibbs

Reputation: 22974

You can rely on code. Error codes do not often change due to backward compatibility. Some may be added. In that case, you need to refer error.md file from the source code of the specific version.

list of codes

16945 code Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUse:true to opt in.

Highlighted portion is one of the possible solution.

Upvotes: 2

Related Questions