由于我真的不知道可能是什么问题,所以我将复制并粘贴错误。我搜索了Google,但到目前为止没有成功。代码的第一部分是我猜到的问题,因此我只添加了第二部分,以防它可能更有用。基本上,几天后,我的数据库就停止工作了,我也不知道为什么。这是MongoDB的云版本,我使用NodeJs + ExpressJs + Mongoose。预先感谢您的所有提示。
0|app | at eachAsync (/home/redicerap/apps/nashinobi/backend/node_mod ules/mongodb/lib/core/utils.js:135:5)
0|app | at Pool.reset (/home/redicerap/apps/nashinobi/backend/node_mo dules/mongodb/lib/core/connection/pool.js:709:3)
0|app | at /home/redicerap/apps/nashinobi/backend/node_modules/mongod b/lib/core/sdam/monitoring.js:202:19
0|app | at /home/redicerap/apps/nashinobi/backend/node_modules/mongod b/lib/core/sdam/monitoring.js:164:18
0|app | at Server.command (/home/redicerap/apps/nashinobi/backend/nod e_modules/mongodb/lib/core/sdam/server.js:239:14)
0|app | at checkServer (/home/redicerap/apps/nashinobi/backend/node_m odules/mongodb/lib/core/sdam/monitoring.js:148:12)
0|app | at Object.monitorServer [as monitorFunction] (/home/redicerap /apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:193:3)
0|app | at Server.monitor (/home/redicerap/apps/nashinobi/backend/nod e_modules/mongodb/lib/core/sdam/server.js:216:12)
0|app | at Timeout.<anonymous> (/home/redicerap/apps/nashinobi/backen d/node_modules/mongodb/lib/core/sdam/topology.js:859:22)
0|app | at listOnTimeout (internal/timers.js:531:17) {
0|app | name: 'MongoError',
0|app | [Symbol(mongoErrorContextSymbol)]: {}
0|app | },
0|app | [Symbol(mongoErrorContextSymbol)]: {}
0|app | }
0|app | MongoTimeoutError: Server selection timed out after 30000 ms
0|app | at Timeout._onTimeout (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/topology.js:878:9)
0|app | at listOnTimeout (internal/timers.js:531:17)
0|app | at processTimers (internal/timers.js:475:7) {
0|app | name: 'MongoTimeoutError',
0|app | reason: MongoError: server instance pool was destroyed
0|app | at basicWriteValidations (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/server.js:408:12)
0|app | at basicReadValidations (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/server.js:415:17)
0|app | at Server.command (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/server.js:237:19)
0|app | at checkServer (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:148:12)
0|app | at /home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:204:7
0|app | at /home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/connection/pool.js:732:9
0|app | at eachAsync (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/utils.js:135:5)
0|app | at Pool.reset (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/connection/pool.js:709:3)
0|app | at /home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:202:19
0|app | at /home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:164:18
0|app | at Server.command (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/server.js:239:14)
0|app | at checkServer (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:148:12)
0|app | at Object.monitorServer [as monitorFunction] (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:193:3)
0|app | at Server.monitor (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/server.js:216:12)
0|app | at Timeout.<anonymous> (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/topology.js:859:22)
0|app | at listOnTimeout (internal/timers.js:531:17) {
0|app | name: 'MongoError',
0|app | [Symbol(mongoErrorContextSymbol)]: {}
0|app | },
0|app | [Symbol(mongoErrorContextSymbol)]: {}
0|app | }
答案 0 :(得分:0)
解决方案非常简单。我在两个不同的地方返回了响应,因为我不喜欢嵌套Mongoose查询。因此,整个NodeJS后端崩溃了,但是很难发现,因为它很少发生,但是经常发生。确保返回res.status(200)或仅返回一次。我在分配给const的每个Mongoose查询中都返回了一个res.status(200),以为还可以,因为第二次返回甚至都没有达到,在大多数情况下都是这样。此错误并不与猫鼬本身有关。