How to debug mongoerror?

限于喜欢 提交于 2021-01-06 03:29:16

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/63296748/how-to-debug-mongoerror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!