Scheduler
Standalone — usable in any Node project, no
@warlock.js/corerequired.
@warlock.js/scheduler runs recurring work inside your Node
process — cleanups, reports, syncs, health pings — without an
external cron daemon or a docker-cron sidecar. Describe a schedule in
plain English (.daily().at("03:00")) or with a cron string
(.cron("0 3 * * *")), pin it to a timezone so DST never shifts your
nightly run, retry on failure with backoff, and watch the whole
lifecycle through typed events.
It is not a distributed queue. Jobs run in the calling process; if the process dies before the next tick, the schedule resumes from now, not from the missed fire time. Need exactly-once-eventually across many replicas? Reach for BullMQ or Temporal — and check the distributed-locking backlog item for where this package is headed.
Try it in fifteen lines
Section titled “Try it in fifteen lines”import { scheduler, job } from "@warlock.js/scheduler";
// Log every failure, register one nightly job, start ticking.scheduler.on("job:error", (name, error) => { console.error(`${name} failed:`, error);});
scheduler.addJob( job("nightly-cleanup", async () => { await db.deleteExpiredTokens(); }) .daily() .at("03:00") .inTimezone("America/New_York") .retry(3, 1000),);
scheduler.start();That is a complete, running scheduler. The singleton is ready to use —
no setup, no config object. From here you add more jobs, listen to more
events, and wire scheduler.shutdown() into your SIGTERM handler.
Read by intent
Section titled “Read by intent”- First time using it → Getting started.
- Understanding the mental model → Essentials.
- Looking up “how do I…?” → Guides.
- Copy-paste a real task → Recipes.
- Method-by-method lookup → Reference.