From d1d63e88231d5c76d1fd000a437471152475e460 Mon Sep 17 00:00:00 2001 From: rozetko Date: Wed, 18 Jan 2023 18:38:09 +0300 Subject: [PATCH] fix queries sometimes failing --- src/routes/tasks.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/routes/tasks.ts b/src/routes/tasks.ts index c03ef20..fa0d902 100644 --- a/src/routes/tasks.ts +++ b/src/routes/tasks.ts @@ -31,8 +31,12 @@ async function getTasks(req, res) { } // TODO: read async let data = fs.readFileSync(path.join(EXPORTED_PATH, item), 'utf8'); - let status = JSON.parse(data); - resp.push(status); + try { + let status = JSON.parse(data); + resp.push(status); + } catch(e) { + console.log(`Cannot read file /exporter/${item}. if this error doesn't repeat, maybe the file is being updated at the moment`); + } } res.status(200).send(resp);