fix(google-sync): skip null items and await initial sync (#93)

Null/undefined items in the Google Calendar API response caused a
TypeError on `item.status` access, silently aborting the sync while
the OAuth callback had already redirected to the success page.

- Filter null items in `upsertGoogleEvents` with an early `continue`
- Await `sync()` in the OAuth callback so errors surface as
  `sync_error=google` redirects instead of false success

Resolves #92

Co-authored-by: Ulas Kalayci <ulas.kalayci@googlemail.com>
This commit is contained in:
ulsklyc
2026-04-27 17:24:37 +02:00
committed by GitHub
parent 0964d3a507
commit 19e6569281
2 changed files with 3 additions and 4 deletions
+1 -3
View File
@@ -268,9 +268,7 @@ router.get('/google/callback', async (req, res) => {
delete req.session.googleOAuthState; delete req.session.googleOAuthState;
await googleCalendar.handleCallback(code); await googleCalendar.handleCallback(code);
await googleCalendar.sync();
// Initialen Sync im Hintergrund starten (kein await - Redirect soll sofort erfolgen)
googleCalendar.sync().catch((e) => log.error('Initial sync failed:', e.message));
res.redirect('/settings?sync_ok=google'); res.redirect('/settings?sync_ok=google');
} catch (err) { } catch (err) {
+2 -1
View File
@@ -303,10 +303,11 @@ function upsertGoogleEvents(items, calRefId = null, calColor = GOOGLE_COLOR) {
}); });
for (const item of items) { for (const item of items) {
if (!item) continue;
try { try {
insertOrUpdate(item); insertOrUpdate(item);
} catch (err) { } catch (err) {
log.error(`Upsert error for event ${item.id}:`, err.message); log.error(`Upsert error for event ${item?.id}:`, err.message);
} }
} }
} }