Overview
Chronos Calendar provides seamless two-way synchronization with Google Calendar, ensuring your events are always up-to-date across all devices. The sync system uses Google’s incremental sync tokens and push notifications for efficient, real-time updates.How Sync Works
- Initial Sync
- Incremental Sync
- Webhook Updates
When you first connect a Google Calendar:
- Full Sync: Chronos fetches all events from your Google Calendar
- Encryption: Event data is encrypted with your user key
- Storage: Events are stored in both Supabase (server) and IndexedDB (local)
- Sync Token: A sync token is saved to enable incremental updates
The initial sync may take longer for calendars with many events. Progress is displayed in real-time.
Syncing Your Calendar
Manual Sync
Click the Sync button in the calendar header to manually trigger a sync:What happens during manual sync
What happens during manual sync
- Connection: Opens an SSE (Server-Sent Events) stream to the backend
- Progress: Displays real-time progress for each calendar
- Event Processing: Events are fetched, encrypted, and stored
- Completion: Shows total events synced and last sync time
Automatic Sync
Chronos automatically syncs your calendars:- Every 10 minutes while the app is open
- On startup when you launch the app
- Via webhooks when Google Calendar sends push notifications
- Smart polling checks for server-side updates every minute
Sync Status Indicators
The calendar header displays sync status:Syncing
Progress bar shows events being fetched and calendars completed
Up to Date
Displays last sync timestamp (e.g., “Synced 2 minutes ago”)
Error
Shows error message with retry option
Needs Reauth
Google account requires re-authentication
Handling Sync Errors
Token Expiration
If a sync token expires (error 410), Chronos automatically:- Clears the expired token
- Performs a fresh full sync
- Saves the new sync token
Rate Limiting
Syncs are rate-limited to once every 5 seconds per user to prevent abuse and quota exhaustion.
Connection Issues
If sync fails due to network issues:- Retryable errors (500, 429, quota): Automatically retried with exponential backoff
- Non-retryable errors (401, 403): Displayed to user with action required
- Timeout: Sync cancelled after 5 minutes (300 seconds)
Multi-Calendar Sync
You can sync up to 20 calendars simultaneously:- Concurrent Fetching: Up to 5 calendars fetched in parallel
- Independent Progress: Each calendar’s progress tracked separately
- Partial Success: If one calendar fails, others continue syncing
Data Privacy
All event data is encrypted at rest using user-specific encryption keys. Even if the database is compromised, your calendar data remains secure.
Troubleshooting
Calendar won't sync
Calendar won't sync
- Check that your Google account doesn’t show “Needs Reauth”
- Try clicking the sync button manually
- Check your internet connection
- Look for error messages in the calendar header
Events are outdated
Events are outdated
- Manual sync: Click the sync button
- Webhooks may not be working: Check server logs for webhook errors
- Browser may be offline: Check network connectivity
Sync keeps failing
Sync keeps failing
- 401 Unauthorized: Re-authenticate your Google account
- 403 Forbidden: Check Google Calendar API quota limits
- 429 Rate Limited: Wait a few minutes before trying again
- 500 Server Error: Google Calendar may be temporarily unavailable
Technical Details
Sync Flow Architecture
- Client Request: Frontend initiates sync via SSE endpoint
- Token Management: Backend refreshes OAuth tokens if needed
- Parallel Fetching: Up to 5 calendars fetched concurrently
- Event Streaming: Events streamed to client as they’re fetched
- Local Storage: Events stored in IndexedDB for offline access
- Webhook Registration: Push notification channels registered/renewed