Allow forwarding node-cron options (e.g. timezone) through .schedule()
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()
That's actually a useful feature. Will implement it this week. Thanks for the suggestion!
:tada: This issue has been resolved in version 1.15.0 :tada:
The release is available on:
v1.15.0- GitHub release
Your semantic-release bot :package::rocket: