Skip to content

Commit

Permalink
Fix startup with no data (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
sachk committed Feb 5, 2024
1 parent 82d7497 commit 6f13a45
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions api/src/load-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ let timer: ReturnType<typeof setTimeout> | null = null;

const loadData = (eventType?: string) => {
const f = () => {
data = JSON.parse(fs.readFileSync(dataLocation, "utf8"));
console.log(`Loaded data (written at ${data.lastUpdated}).`);
try {
data = JSON.parse(fs.readFileSync(dataLocation, "utf8"));
console.log(`Loaded data (written at ${data.lastUpdated}).`);
} catch (err) {
console.log(`Failed loading data error ${err}.`);
}
};

if (eventType) {
if (timer != null) {
clearTimeout(timer);
Expand Down

0 comments on commit 6f13a45

Please sign in to comment.