From 19e65692814b9a95dc5dda640ba7052be7aa4db9 Mon Sep 17 00:00:00 2001 From: ulsklyc <108589275+ulsklyc@users.noreply.github.com> Date: Mon, 27 Apr 2026 17:24:37 +0200 Subject: [PATCH] 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 --- server/routes/calendar.js | 4 +--- server/services/google-calendar.js | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/server/routes/calendar.js b/server/routes/calendar.js index 4b7e186..e0c2b49 100644 --- a/server/routes/calendar.js +++ b/server/routes/calendar.js @@ -268,9 +268,7 @@ router.get('/google/callback', async (req, res) => { delete req.session.googleOAuthState; await googleCalendar.handleCallback(code); - - // Initialen Sync im Hintergrund starten (kein await - Redirect soll sofort erfolgen) - googleCalendar.sync().catch((e) => log.error('Initial sync failed:', e.message)); + await googleCalendar.sync(); res.redirect('/settings?sync_ok=google'); } catch (err) { diff --git a/server/services/google-calendar.js b/server/services/google-calendar.js index 662b9f0..9d2b7aa 100644 --- a/server/services/google-calendar.js +++ b/server/services/google-calendar.js @@ -303,10 +303,11 @@ function upsertGoogleEvents(items, calRefId = null, calColor = GOOGLE_COLOR) { }); for (const item of items) { + if (!item) continue; try { insertOrUpdate(item); } catch (err) { - log.error(`Upsert error for event ${item.id}:`, err.message); + log.error(`Upsert error for event ${item?.id}:`, err.message); } } }