fix: use Promise.allSettled for calendar fetching

A transient error on one calendar (e.g. shared calendar
with permission issues) no longer discards results from
all other calendars.

Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
2026-02-14 00:44:47 +00:00
parent f557a0f967
commit 6c4982ae85

View File

@@ -98,7 +98,7 @@ export class CalendarSource implements FeedSource<CalendarFeedItem> {
const { start, end } = computeTimeRange(context.time, this.lookAheadDays) const { start, end } = computeTimeRange(context.time, this.lookAheadDays)
const results = await Promise.all( const results = await Promise.allSettled(
calendars.map(async (calendar) => { calendars.map(async (calendar) => {
const objects = await client.fetchCalendarObjects({ const objects = await client.fetchCalendarObjects({
calendar, calendar,
@@ -115,7 +115,9 @@ export class CalendarSource implements FeedSource<CalendarFeedItem> {
) )
const allEvents: CalendarEventData[] = [] const allEvents: CalendarEventData[] = []
for (const { objects, calendarName } of results) { for (const result of results) {
if (result.status !== "fulfilled") continue
const { objects, calendarName } = result.value
for (const obj of objects) { for (const obj of objects) {
if (typeof obj.data !== "string") continue if (typeof obj.data !== "string") continue