Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions apps/webapp/app/v3/services/createBackgroundWorker.server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,43 @@ describe("syncDeclarativeSchedules registration", () => {
}
);

containerTest(
"preserves an existing Redis job when task schedule omits explicit UTC timezone",
async ({ prisma, redisOptions }) => {
const { project, prodEnv } = await seedProjectWithEnvs(prisma);
const schedule = await makeDeclarativeSchedule(prisma, project.id, [prodEnv.id]);
const updatedAt = schedule.updatedAt;
await seedScheduledTask(prisma, project.id, prodEnv.id);
const engine = createTestScheduleEngine(prisma, redisOptions);

try {
const jobId = scheduleJobId(schedule.instances[0].id);
await engine.registerNextTaskScheduleInstance({ instanceId: schedule.instances[0].id });
const before = await engine.getJob(jobId);

// 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.

noWorker,
asEnv(prodEnv),
prisma,
engine
);

expect(before).toBeDefined();
expect(await engine.getJob(jobId)).toEqual(before);
expect(
await prisma.taskSchedule.findUniqueOrThrow({
where: { id: schedule.id },
select: { updatedAt: true },
})
).toEqual({ updatedAt });
} finally {
await engine.quit();
}
}
);

containerTest(
"replaces the Redis job when declarative timing changes",
async ({ prisma, redisOptions }) => {
Expand Down
13 changes: 8 additions & 5 deletions apps/webapp/app/v3/services/createBackgroundWorker.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ export async function syncDeclarativeSchedules(
environment.projectId,
{
cron: task.schedule.cron,
timezone: task.schedule.timezone,
timezone: task.schedule.timezone ?? "UTC",
taskIdentifier: task.id,
friendlyId: existingSchedule?.friendlyId,
window: task.schedule.window,
Expand Down Expand Up @@ -1623,15 +1623,18 @@ export async function syncDeclarativeSchedules(
windowPercentage: normalizedWindow.windowPercentage,
defaultWindowDurationSeconds: existingSchedule.defaultWindowDurationSeconds,
}).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.

const timingChanged =
existingSchedule.generatorExpression !== task.schedule.cron ||
existingSchedule.timezone !== task.schedule.timezone ||
timezoneChanged ||
!scheduleWindowsEqual(previousWindow, nextWindow) ||
// Clearing the minimum changes the effective range.
existingSchedule.minimumWindowDurationSeconds !== minimumWindowDurationSeconds;
const persistedValuesChanged =
existingSchedule.generatorExpression !== task.schedule.cron ||
existingSchedule.timezone !== task.schedule.timezone ||
timezoneChanged ||
existingSchedule.windowDurationSeconds !== normalizedWindow.windowDurationSeconds ||
existingSchedule.windowPercentage !== normalizedWindow.windowPercentage ||
existingSchedule.minimumWindowDurationSeconds !== minimumWindowDurationSeconds;
Expand All @@ -1643,7 +1646,7 @@ export async function syncDeclarativeSchedules(
data: {
generatorExpression: task.schedule.cron,
generatorDescription: cronstrue.toString(task.schedule.cron),
timezone: task.schedule.timezone,
timezone: taskTimezone,
minimumWindowDurationSeconds,
...normalizedWindow,
},
Expand Down Expand Up @@ -1675,7 +1678,7 @@ export async function syncDeclarativeSchedules(
taskIdentifier: task.id,
generatorExpression: task.schedule.cron,
generatorDescription: cronstrue.toString(task.schedule.cron),
timezone: task.schedule.timezone,
timezone: task.schedule.timezone ?? "UTC",
type: "DECLARATIVE",
minimumWindowDurationSeconds,
...normalizedWindow,
Expand Down