WiserSolutions/quadro

Mongo metrics bugfix

andrii33 opened this issue · 1 comments

Brief issue description

Fix the case when result is undefined

Example

`{"name":"pricing_stats_service","hostname":"ip-10-100-174-60","pid":18,"level":30,"port":"3030","msg":"HTTP Server listening","time":"2020-04-08T11:34:22.298Z","v":0}
/app/node_modules/quadro/services/mongo.js:87
if ('then' in result) {
^
TypeError: Cannot use 'in' operator to search for 'then' in undefined
at Collection.metricsFunctionWrapper [as findOneAndUpdate] (/app/node_modules/quadro/services/mongo.js:87:16)
at Agenda.module.exports [as _findAndLockNextJob] (/app/node_modules/agenda/lib/agenda/find-and-lock-next-job.js:72:22)
at jobQueueFilling (/app/node_modules/agenda/lib/utils/process-jobs.js:200:10)
at Agenda.module.exports (/app/node_modules/agenda/lib/utils/process-jobs.js:32:9)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
/app/node_modules/quadro/services/mongo.js:87
if ('then' in result) {
^
TypeError: Cannot use 'in' operator to search for 'then' in undefined
at Collection.metricsFunctionWrapper [as findOneAndUpdate] (/app/node_modules/quadro/services/mongo.js:87:16)
at Agenda.module.exports [as _findAndLockNextJob] (/app/node_modules/agenda/lib/agenda/find-and-lock-next-job.js:72:22)
at jobQueueFilling (/app/node_modules/agenda/lib/utils/process-jobs.js:200:10)
at Agenda.module.exports (/app/node_modules/agenda/lib/utils/process-jobs.js:32:9)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
{"name":"pricing_stats_service","hostname":"ip-10-100-174-60","pid":1,"level":30,"msg":"Worker 19 exited with code 1 from signal null.","time":"2020-04-08T11:34:27.284Z","v":0}
[ec2-user@ip-10-100-174-60 ~]$

See PR #402