Skip to content

fix: do not enqueue Google Calendar sync when export is disabled (closes #2040)#2053

Open
ther12k wants to merge 1 commit into
callumalpass:mainfrom
ther12k:fix/issue-2040-google-calendar-sync-queue
Open

fix: do not enqueue Google Calendar sync when export is disabled (closes #2040)#2053
ther12k wants to merge 1 commit into
callumalpass:mainfrom
ther12k:fix/issue-2040-google-calendar-sync-queue

Conversation

@ther12k

@ther12k ther12k commented Jun 21, 2026

Copy link
Copy Markdown

Fixes #2040.

Root cause
syncTaskToCalendar in src/services/TaskCalendarSyncService.ts enqueues entries into googleCalendarSyncQueue even when settings.googleCalendarExport.enabled === false. The check happens later in the pipeline, after the queue interaction, so disabled users see queue churn and retry attempts they never asked for.

Fix
Early-return at the top of syncTaskToCalendar when settings.googleCalendarExport.enabled === false, before any queue interaction. Transient-failure queueing for users who do have export enabled is preserved.

Tests

  • Added 3 new tests in tests/unit/issues/issue-2040-google-calendar-sync-queue.test.ts:
    1. disabled user → no enqueue, no retry attempt
    2. enabled user → still enqueues on transient failure (regression guard)
    3. enabled user → completes normally without queue growth
  • All 38 sync-service suites pass.

Notes

… (issue callumalpass#2040)

When a user installed TaskNotes and created tasks without ever enabling the
Google Calendar export integration, every eligible task (those with a
scheduled or due date) would append an entry to googleCalendarSyncQueue in
data.json. The queue was being populated with entries like:

  'lastError': 'Google Calendar sync is not ready'

This happened because:
  1. TaskCreationService calls syncTaskToCalendar for every task when
     googleCalendarExport.syncOnTaskCreate === true.
  2. syncTaskToCalendar passes the eligibility check (any task with
     scheduled/due is eligible per settings.googleCalendarExport.syncTrigger).
  3. syncTaskToCalendar reaches the 'if (!this.isEnabled())' branch.
  4. isEnabled() returns false because the user never configured the
     integration, so queueTaskSync is called with 'sync not ready'.
  5. The queue entry is persisted to data.json.
  6. Nothing ever clears it because the queue is intended for transient
     failures that the recovery loop processes; a permanent 'never
     configured' state never recovers.

The queue is for transient failures (auth expired, rate limited, target
calendar temporarily missing). When the user has opted out of the feature
entirely, there is nothing to recover from.

Fix: add an early-return at the top of syncTaskToCalendar when
settings.googleCalendarExport.enabled === false. This applies to every
caller (TaskCreationService, taskNotesCommands, TaskContextMenu, the
periodic sync loop) without needing a guard at each call site. The
existing isEnabled() check below is preserved unchanged so that transient
failures while the feature IS enabled still queue as before.

Adds tests/unit/issues/issue-2040-google-calendar-sync-queue.test.ts with
three cases:
  - export disabled → syncTaskToCalendar returns true, queueTaskSync not called
  - export enabled but isEnabled() false (e.g. OAuth disconnected) → queueTaskSync IS called (preserves existing behavior)
  - ineligible task + export disabled → no-op, no queue interaction

Closes callumalpass#2040
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.

[Bug]: googleCalendarSyncQueue fills up without a calendar configured

1 participant