fzaninotto/uptime

Cannot read property 'firstTested' of null when deleting a check with a huge history

Opened this issue ยท 0 comments

Hi there,

We are using this great project to our company.
Our uptime have approximately 130 checks with 3 months history limit.
Total of pings ? Actually ~9M ! ๐Ÿ˜„

So when we want to delete an old check with a lot of pings, that take lot of time and finish with a crash of the app...

Here, the error:

Mongoose: checkhourlystats.update({ check: ObjectId("52c2d0c3ac26817a5913a51d"), timestamp: new Date("Tue, 10 Jun 2014 13:00:00 GMT") }) { '$set': { check: ObjectId("52c2d0c3ac26817a5913a51d"), timestamp: new Date("Tue, 10 Jun 2014 13:00:00 GMT"), count: 1, responsiveness: 1, responseTime: 365, downtime: 0, availability: 1 } } { safe: undefined, upsert: true } 
Mongoose: checkhourlystats.update({ check: ObjectId("52a6dc91ac26817a5901535f"), timestamp: new Date("Tue, 10 Jun 2014 13:00:00 GMT") }) { '$set': { check: ObjectId("52a6dc91ac26817a5901535f"), timestamp: new Date("Tue, 10 Jun 2014 13:00:00 GMT"), count: 1, responsiveness: 1, responseTime: 268, downtime: 0, availability: 1 } } { safe: undefined, upsert: true } 

/uptime/node_modules/mongoose/lib/utils.js:413
        throw err;
              ^
TypeError: Cannot read property 'firstTested' of null
    at IntervalBuilder.calculateDuration (/uptime/lib/intervalBuilder.js:100:44)
    at Array.async.auto.duration [as 3] (/uptime/lib/intervalBuilder.js:48:14)
    at listener (/uptime/node_modules/async/lib/async.js:412:46)
    at /uptime/node_modules/async/lib/async.js:371:17
    at Array.forEach (native)
    at _forEach (/uptime/node_modules/async/lib/async.js:26:24)
    at taskComplete (/uptime/node_modules/async/lib/async.js:370:13)
    at Promise.taskCallback (/uptime/node_modules/async/lib/async.js:396:21)
    at Promise.<anonymous> (/uptime/node_modules/mongoose/node_modules/mpromise/lib/promise.js:162:8)
    at Promise.EventEmitter.emit (events.js:95:17)

It seems Uptime tried to update to that check being deleted and crash because it doesn't exist anymore. Am I right ?

Maybe we have to add a flag deleting to the check in order to tell the app to not manage it...

What do you think ?

I guess this issue is related to #218 but not sure...

Thanks !