From 74854387cdf10237187a977869eebbbf44a4c28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bugsounet=20-=20C=C3=A9dric?= Date: Mon, 4 Dec 2023 07:34:14 +0100 Subject: [PATCH] Fix updatenotification (#3281) Sometime, `pm2 jlist` don't send an json reponse Catch error if happen --------- Co-authored-by: bugsounet --- CHANGELOG.md | 1 + modules/default/updatenotification/update_helper.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3045f85b5..fa4cb45036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ _This release is scheduled to be released on 2024-01-01._ - Fix #3256 filter out bad results from rrule.between - Fix calendar events sometimes not respecting deleted events (#3250) - Fix electron loadurl locally on Windows when address "0.0.0.0" (#2550) +- Fix updatanotification (update_helper.js): catch error if reponse is not an JSON format (check PM2) ## [2.25.0] - 2023-10-01 diff --git a/modules/default/updatenotification/update_helper.js b/modules/default/updatenotification/update_helper.js index 532472075c..41eb66b458 100644 --- a/modules/default/updatenotification/update_helper.js +++ b/modules/default/updatenotification/update_helper.js @@ -198,8 +198,14 @@ class Updater { resolve(null); return; } - let result = JSON.parse(std); - resolve(result); + try { + let result = JSON.parse(std); + resolve(result); + } catch (e) { + Log.error("updatenotification: [PM2] can't GetList!"); + Log.debug("updatenotification: [PM2] GetList is not an JSON format", e); + resolve(null); + } }); }); }