Skip to content

Commit 08f91ad

Browse files
committed
Safely catch issues with iCal download
1 parent da248c9 commit 08f91ad

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

index.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -962,9 +962,14 @@ function cleanNotes() {
962962
let locationToNowAndNextEvents = {};
963963
let iCalendar = {};
964964
async function updateCalendarFromRemote() {
965-
iCalendar = await ical.async.fromURL(
966-
`https://www.recurse.com/calendar/events.ics?token=${recurseCalendarToken}&omit_cancelled_events=1&scope=all`,
967-
);
965+
try {
966+
iCalendar = await ical.async.fromURL(
967+
`https://www.recurse.com/calendar/events.ics?token=${recurseCalendarToken}&omit_cancelled_events=1&scope=all`,
968+
);
969+
} catch (error) {
970+
console.error("Failed to fetch calendar ICS, will try again. Error:");
971+
console.error(error);
972+
}
968973
clearTimeout(timeoutIdForUpdateRoomsAsCalendarEventsChangeOverTime);
969974
updateRoomsAsCalendarEventsChangeOverTime();
970975

@@ -1038,6 +1043,8 @@ function updateRoomsAsCalendarEventsChangeOverTime() {
10381043
emitter.emit("room-change", "events", "changed for", roomName);
10391044
});
10401045

1046+
// This isn't necessary right now, but possible source of a confusing bug
1047+
clearTimeout(timeoutIdForUpdateRoomsAsCalendarEventsChangeOverTime);
10411048
timeoutIdForUpdateRoomsAsCalendarEventsChangeOverTime = setTimeout(
10421049
updateRoomsAsCalendarEventsChangeOverTime,
10431050
calendarUpdateDelay,

0 commit comments

Comments
 (0)