Skip to content

fix(schedules): normalize default UTC timezone before declarative schedule diff (#5066) - #5069

Closed
MilindChatrabhuji wants to merge 1 commit into
triggerdotdev:mainfrom
MilindChatrabhuji:fix/declarative-schedule-timezone-sync-5066
Closed

MilindChatrabhuji wants to merge 1 commit into
triggerdotdev:mainfrom
MilindChatrabhuji:fix/declarative-schedule-timezone-sync-5066

Conversation

@MilindChatrabhuji

Copy link
Copy Markdown

Overview

Fixes #5066

Problem

When syncing declarative task schedules where the task schedule definition omits an explicit timezone (e.g. schedules.task({ cron: "0 * * * *" })), task.schedule.timezone is undefined. Because the database model TaskSchedule defaults to "UTC", comparing existingSchedule.timezone ("UTC") against task.schedule.timezone (undefined) evaluated to true on every single deployment:

const timingChanged = existingSchedule.timezone !== task.schedule.timezone;

This falsely marked declarative schedules as modified on each deployment, triggering unnecessary database updates and unneeded schedule re-registrations.

Solution

  • Normalized task and database timezones with a default "UTC" fallback before evaluating timingChanged and persistedValuesChanged:
    const taskTimezone = task.schedule.timezone ?? "UTC";
    const existingTimezone = existingSchedule.timezone ?? "UTC";
    const timezoneChanged = existingTimezone !== taskTimezone;
  • Guaranteed "UTC" default normalization during schedule creation (task.schedule.timezone ?? "UTC") and quota checks (checkSchedule.call).
  • Added comprehensive unit test in createBackgroundWorker.server.test.ts verifying that existing schedules and Redis jobs are preserved when a deployment schedule omits an explicit UTC timezone.

@algora-pbc /claim #5066

@changeset-bot

changeset-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 70402ed

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Hi @MilindChatrabhuji, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this Oct 26, 2026
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

Devin Review

}).window;
const taskTimezone = task.schedule.timezone ?? "UTC";
const existingTimezone = existingSchedule.timezone ?? "UTC";
const timezoneChanged = existingTimezone !== taskTimezone;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Schedule fix missing release note

When timezoneChanged preserves a pending run across redeployments, users gain a visible scheduling fix. No server change note announces it.

Learn more

The server-only change stops unchanged UTC schedules from losing their pending job on redeployment. That can affect when a user's task runs. The server change policy requires a release note for a user-facing server fix.

Example: A customer redeploys an hourly task with no explicit timezone. Its pending run now remains scheduled, but the customer sees no mention of the fix in the release notes.

Recommended fix: Add a .server-changes/ entry with area: webapp and type: fix, describing the scheduling behavior in user-facing language.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.


// Omit explicit timezone to verify default UTC normalization does not trigger false timing change
await syncDeclarativeSchedules(
declarativeTasks({ cron: "0 * * * *" }),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Test bypasses normal SDK metadata

The test omits timezone through a cast, but scheduled task registration emits "UTC" for omitted zones. Check whether deployed clients produce metadata this test represents.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

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.

Declarative schedule sync detects false updates when comparing default UTC timezone

1 participant