fix catching detector events when many posts happen simultaneously

cron-addstorage-fix
Moe 2021-09-27 20:08:18 -07:00
parent 659fdb93d1
commit b922258a13
1 changed files with 8 additions and 2 deletions

View File

@ -904,12 +904,17 @@ module.exports = function(s,config,lang){
if(e.details.detector_pam === '1'){
// s.group[e.ke].activeMonitors[e.id].spawn.stdio[3].pipe(s.group[e.ke].activeMonitors[e.id].p2p).pipe(s.group[e.ke].activeMonitors[e.id].pamDiff)
s.group[e.ke].activeMonitors[e.id].spawn.stdio[3].on('data',function(buf){
let theJson
try{
buf.toString().split('}{').forEach((object,n)=>{
var theJson = object
theJson = object
if(object.substr(object.length - 1) !== '}')theJson += '}'
if(object.substr(0,1) !== '{')theJson = '{' + theJson
var data = JSON.parse(theJson)
try{
var data = JSON.parse(theJson)
}catch(err){
var data = JSON.parse(theJson + '}')
}
switch(data.f){
case'trigger':
triggerEvent(data)
@ -920,6 +925,7 @@ module.exports = function(s,config,lang){
}
})
}catch(err){
console.log(theJson)
console.log('There was an error parsing a detector event')
console.log(err)
}