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);