sidequest icon indicating copy to clipboard operation
sidequest copied to clipboard

Allow forwarding node-cron options (e.g. timezone) through .schedule()

Open resentment-industries opened this issue 7 months ago • 2 comments

Problem

JobBuilder.schedule() currently hardcodes the options passed to node-cron:

// packages/engine/src/job/job-builder.ts
const scheduledTask = nodeCron.schedule(
  cronExpression,
  async () => { /* … */ },
  { noOverlap: true },
);

That means there's no supported way to set timezone, even though node-cron@^4.2.1 (the version Sidequest depends on) accepts it.

Use case

We deploy across multiple regions and want recurring jobs to fire on local business hours, not server-local / UTC time. Right now we either drop down to node-cron directly (and lose the ScheduledJobRegistry cleanup wiring) or monkey-patch JobBuilder.

Proposed API

A chainable setter on JobBuilder, mirroring the existing .queue(), .timeout(), .unique(), .retryDelay(), .backoffStrategy() style:

Sidequest.build(MyJob)
  .scheduleOptions({ timezone: "Australia/Brisbane" })
  .schedule("0 9 * * *");

Existing callers stay untouched:

Sidequest.build(MyJob).schedule("*/10 * * * * *");           // unchanged
Sidequest.build(MyJob).schedule("0 * * * *", "foo", 42);     // ...args still flow to run()

resentment-industries avatar Apr 28 '26 00:04 resentment-industries

That's actually a useful feature. Will implement it this week. Thanks for the suggestion!

GiovaniGuizzo avatar Apr 28 '26 12:04 GiovaniGuizzo

:tada: This issue has been resolved in version 1.15.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sidequest-release[bot] avatar May 03 '26 14:05 sidequest-release[bot]