Skip to content

Conversation

@tyler-dane
Copy link
Contributor

@tyler-dane tyler-dane commented Feb 1, 2026

Closes #1422

  • Updated restartGoogleCalendarSync method to accept an options parameter for forced synchronization.
  • Modified error handling in SyncController and error.express.handler to utilize the new forced restart functionality.
  • Enhanced tests to cover scenarios for both forced and non-forced sync operations, ensuring correct behavior based on user import status.

This change improves the flexibility of the Google Calendar synchronization process, allowing for more robust handling of sync operations in various states.


Note

Medium Risk
Changes affect Google Calendar sync control flow and can trigger additional stop/start imports under error conditions; incorrect forcing logic could cause unnecessary resyncs or load, but is scoped and covered by tests.

Overview
Google Calendar sync restarts can now be forced. restartGoogleCalendarSync accepts an options arg ({ force?: boolean }) and will skip restarts when the user’s import is already completed, unless force is set (still avoids interrupting an active importing run).

Error paths that detect isFullSyncRequired (Express Google error handler, sync notification controller, and watch maintenance refresh) now trigger a forced restart to ensure a full resync proceeds even if metadata says import previously finished. Tests add coverage for forced vs non-forced restart behavior.

Written by Cursor Bugbot for commit 6039660. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings February 1, 2026 21:58
@tyler-dane tyler-dane changed the title feat(sync): enhance Google Calendar sync process with forced restart … fix: update 410 error handling with force flag Feb 1, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances Google Calendar sync handling, particularly for 410 GONE / fullSyncRequired scenarios, by adding a “forced” restart path and wiring it into relevant error flows so that a full resync actually runs even when metadata indicates a completed import.

Changes:

  • Updated UserService.restartGoogleCalendarSync to accept an optional { force?: boolean } parameter and adjusted its internal gating to allow forced restarts except when an import is already in progress.
  • Modified sync maintenance (refreshWatch), SyncController webhook handling, and the Express error handler to call restartGoogleCalendarSync with { force: true } when isFullSyncRequired is detected.
  • Extended UserService tests to verify behavior for completed imports in both forced and non-forced restart scenarios.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/backend/src/user/services/user.service.ts Adds a force option to restartGoogleCalendarSync and adjusts the decision logic for when to perform a full Google Calendar import.
packages/backend/src/user/services/user.service.test.ts Introduces tests validating that restarts are skipped for completed imports when not forced, and executed when forced, while preserving metadata semantics.
packages/backend/src/sync/services/maintain/sync.maintenance.ts On fullSyncRequired during watch refresh, now triggers a forced Google Calendar resync for the affected user.
packages/backend/src/sync/controllers/sync.controller.ts When webhook handling detects fullSyncRequired, it now initiates a forced Google Calendar resync.
packages/backend/src/common/errors/handlers/error.express.handler.ts For Google API errors requiring full sync, now triggers a forced resync via restartGoogleCalendarSync and returns an appropriate response.

@tyler-dane tyler-dane changed the title fix: update 410 error handling with force flag fix(backend): update 410 error handling with force flag Feb 1, 2026
…option

- Updated `restartGoogleCalendarSync` method to accept an options parameter for forced synchronization.
- Modified error handling in `SyncController` and `error.express.handler` to utilize the new forced restart functionality.
- Enhanced tests to cover scenarios for both forced and non-forced sync operations, ensuring correct behavior based on user import status.

This change improves the flexibility of the Google Calendar synchronization process, allowing for more robust handling of sync operations in various states.
@tyler-dane tyler-dane force-pushed the fix/1422-410-sync-handling branch from 94435e4 to 6039660 Compare February 1, 2026 22:12
@tyler-dane
Copy link
Contributor Author

tyler-dane commented Feb 1, 2026

Looks good, logs working in prod

0|backend  | 26-02-01 22:15:29 [warn] app:user.service: Restarting Google Calendar sync for user: user1 (forced)
0|backend  | 200 POST /api/sync/gcal/notifications 453.986ms Sun, 01 Feb 2026 22:15:29 GMT
0|backend  | 26-02-01 22:15:30 [debug] app:sync.service: Stopping all gcal event watches for user: user1
0|backend  | 26-02-01 22:15:32 [debug] app:sync.helpers: REMINDER: Channel will expire in 7200 minutes (5 days)
0|backend  | 26-02-01 22:15:33 [info] app:sync.import: Starting importAllEvents for user user1, calendar user1@gmail.com.
0|backend  | 26-02-01 22:15:34 [debug] app:mongo.service: Connected to database: 'xyz'
0|backend  | 26-02-01 22:15:34 [info] app:sync.service: events sync initialized for channelId: 697fd084463b014d0e569252
0|backend  | 200 POST /api/sync/gcal/notifications 2.197ms Sun, 01 Feb 2026 22:15:34 GMT
0|backend  | 26-02-01 22:15:34 [info] app:sync.service: calendarlist sync initialized for channelId: 697fd084463b014d0e569251
0|backend  | 200 POST /api/sync/gcal/notifications 1.514ms Sun, 01 Feb 2026 22:15:34 GMT
0|backend  | 26-02-01 22:15:36 [info] app:sync.import: importAllEvents completed for user1@gmail.com.
0|backend  |     Max results / page: 2500
0|backend  |     Total GCal events processed: 2571.
0|backend  |     Total base/single saved: 239,
0|backend  |     Total instances saved: 2323.
0|backend  |     Total Saved/Changed Compass Events: 2562.
0|backend  |     Duration: 2.56s
0|backend  |     Final nextSyncToken acquired.

@tyler-dane tyler-dane merged commit d5b2c04 into main Feb 1, 2026
6 checks passed
@tyler-dane tyler-dane deleted the fix/1422-410-sync-handling branch February 1, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix 410 GONE flow

1 participant