Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
6b0b814
Implement in-process callback-style Bun.cron (#7004)
alii Mar 31, 2026
6a64dbc
[autofix.ci] apply automated fixes
autofix-ci[bot] Mar 31, 2026
be14e09
Fix JSDoc comment — escape */ in cron expression example
alii Mar 31, 2026
436a4d5
Match setTimeout error semantics for cron callbacks
alii Mar 31, 2026
dc34784
Address review feedback: per-VM job map, validate before replace
alii Mar 31, 2026
1d8acc8
Fix JSDoc example: use absolute URL in fetch
alii Mar 31, 2026
e7422f0
Add CronJob._fire() to make firing tests instant
alii Mar 31, 2026
da3d51f
Revert "Add CronJob._fire() to make firing tests instant"
alii Mar 31, 2026
a877424
make it disposable also always clear on --hot and remove the requirem…
alii Apr 1, 2026
b885965
Address review feedback and simplify CronJob
alii Apr 1, 2026
62f3b9c
Use Promise.withResolvers in cron firing tests
alii Apr 1, 2026
5d70794
Clear cron jobs on worker termination; deterministic --hot test
alii Apr 1, 2026
f85aca1
Anchor cron to real time; suppress rejection for stopped jobs
alii Apr 1, 2026
ec0d8ee
Move cron jobs list to per-VM RareData
alii Apr 1, 2026
520ff90
Address review: ref/deref bracket in onTimerFire, pass job as this
alii Apr 1, 2026
8246306
Exclude CronJob from fake timers; release callback on stop; bun.Strin…
alii Apr 1, 2026
cb6adce
docs: add in-process Bun.cron(schedule, handler) section
alii Apr 1, 2026
f71fc85
Store callback and pendingPromise as WriteBarrier values, rename poll…
alii Apr 1, 2026
080ccc3
Support fake timers in Bun.cron; address Jarred review
alii Apr 1, 2026
56a6d21
Surface rejections after stop; free cron_jobs buffer in RareData.deinit
alii Apr 1, 2026
789f3cb
Reset date_now_offset when setSystemTime() is called with no args
alii Apr 2, 2026
4807d6c
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 2, 2026
46db234
Inline single-use helpers in CronJob and trim narrative comments
alii Apr 2, 2026
8aa7e88
Revert fake-timer support for cron; balance pending ref on VM teardown
alii Apr 2, 2026
188aedd
Defer this_value downgrade until pending promise settles
alii Apr 2, 2026
fcdd580
Test: drop reference + GC before reject to verify wrapper stays strong
alii Apr 2, 2026
de04dc8
Defer stop() cleanup when called during cb.call()
alii Apr 2, 2026
d19ce67
Unref poll_ref immediately in deferred-stop path
alii Apr 2, 2026
1641875
cron: interpret schedules in local time instead of UTC
alii Apr 2, 2026
ca0f099
docs: clarify spring-forward DST skips to next occurrence
alii Apr 2, 2026
c0ae5e8
Fix stray UTC reference in cron_parser module comment
alii Apr 2, 2026
282b60b
cron_parser: guard against fall-back returning a time before from_ms
alii Apr 2, 2026
fb7a836
Use describe.concurrent for cron-local-time subprocess tests
alii Apr 2, 2026
4efefa5
Merge branch 'main' into ali/in-process-cron
alii Apr 2, 2026
79f99cb
cron_parser: spring-forward fires same day; selfStop defers when pend…
alii Apr 2, 2026
397186b
Reword noon round-trip comment: midday DST shifts stay same calendar day
alii Apr 2, 2026
aac6816
scheduleNext: use finishDeferredStop on natural-expiry; fix month/wee…
alii Apr 2, 2026
e651c78
cron: relax handler return type to unknown
alii Apr 2, 2026
2e7453d
cron: fix Windows OS-level leaks (stderr_reader, envp arena)
alii Apr 2, 2026
91061fa
cron_parser: fold weekday 7→0 after range expansion, not before
alii Apr 2, 2026
b60a308
cron: address deep-review findings
alii Apr 2, 2026
b297206
cron: fall-back wild schedules fire through repeated hour (cronie sem…
alii Apr 2, 2026
ef368f6
cron: simplify — extract matchesDay, dedupe all_* constants, name sca…
alii Apr 2, 2026
7d659e5
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 2, 2026
143420b
cron: deep-simplify — handleOom ladders, merge C++ date externs, fix …
alii Apr 2, 2026
97b8a59
cron: --hot test writes markers outside watched dir (avoid watcher/ex…
alii Apr 2, 2026
6a9b1d6
cron_parser: hoist year bound into loop condition
alii Apr 2, 2026
3e0005e
cron: fix WindowsBufferedReader.deinit pipe leak; clearAllForVM in ma…
alii Apr 2, 2026
7b64fa6
cron_parser: drop date_dirty — noon round-trip is cheap (dateCache), …
alii Apr 2, 2026
9b4ab11
cron_parser: extract resolveLocalMatch — next() is now purely the wal…
alii Apr 2, 2026
3a61b3b
cron: add Lord Howe 30-min fall-back tests + hourly chain tests throu…
alii Apr 2, 2026
b9415aa
cron: parse() and in-process callback are UTC; drop local-time/DST ha…
alii Apr 2, 2026
61b1f24
cron: remove dead raw_schedule field
alii Apr 2, 2026
3bb7e12
Merge branch 'main' into ali/in-process-cron
alii Apr 2, 2026
3ed45d0
cron: skip cron_jobs list ref+append when not --hot and not a worker
alii Apr 3, 2026
892a093
cron: drop stale TZ-pinning in cron.test.ts; remove duplicate "may" i…
alii Apr 3, 2026
2b384d5
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 3, 2026
cb9abd1
cron: validate bun_exe path for ' and % before crontab embed
alii Apr 3, 2026
647c66f
Merge branch 'main' into ali/in-process-cron
alii Apr 3, 2026
a9b5e5a
Revert PipeReader.zig deinit reorder; fail-fast --hot test polls; bum…
alii Apr 3, 2026
e5a57b8
cron.test.ts: poll for marker instead of fs.watch(/tmp) (macOS symlin…
alii Apr 3, 2026
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
87 changes: 84 additions & 3 deletions docs/runtime/cron.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ title: Cron
description: Schedule and parse cron jobs with Bun
---

Bun has built-in support for registering OS-level cron jobs and parsing cron expressions.
Bun has built-in support for cron — parse expressions, run a callback on a schedule inside your process, or register OS-level jobs that survive restarts.

## Quickstart

**Run a callback on a schedule in the current process:**

```ts
Bun.cron("0 * * * *", async () => {
await cleanupTempFiles();
});
```

**Parse a cron expression to find the next matching time:**

```ts
Expand All @@ -15,7 +23,7 @@ const next = Bun.cron.parse("30 9 * * MON-FRI");
console.log(next); // => 2025-01-20T09:30:00.000Z
```

**Register a cron job that runs a script on a schedule:**
**Register an OS-level cron job that runs a script on a schedule:**

```ts
await Bun.cron("./worker.ts", "30 2 * * MON", "weekly-report");
Expand Down Expand Up @@ -124,7 +132,80 @@ When only one is specified (the other is `*`), only that field is used for match

---

## `Bun.cron()`
## `Bun.cron(schedule, handler)` — in-process

Run a callback on a cron schedule inside the current process.

```ts
const job = Bun.cron("*/5 * * * *", async () => {
await syncToDatabase();
});
```

This is the lightweight option for long-running servers and workers — no system cron daemon required, works the same on every platform, and shares state (database pools, caches, module-level variables) between invocations.

| | In-process | [OS-level](#bun-cron-path-schedule-title-os-level) |
| ---------------------------- | -------------------------------- | -------------------------------------------------- |
| Survives process exit/reboot | No | Yes |
| Shared state between runs | Yes | No (fresh process each time) |
| Platform requirements | None | crontab / launchd / Task Scheduler |
| Windows expression limits | None | [48-trigger cap](#trigger-limit) |
| Return type | [`CronJob`](#the-cronjob-handle) | `Promise<void>` |

### Parameters

| Parameter | Type | Description |
| ---------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
| `schedule` | `string` | A [cron expression](#cron-expression-syntax) or nickname like `"@hourly"`. |
| `handler` | `(this: CronJob) => void \| Promise<void>` | Called on each fire. Inside a `function` callback, `this` is the `CronJob` (so `this.stop()` works). |

Returns a [`CronJob`](#the-cronjob-handle) synchronously. Throws a `TypeError` if the expression is invalid or has no future occurrences (e.g. `"0 0 30 2 *"` — February 30th).

### No-overlap guarantee

The next fire time is computed only after the handler — including any returned `Promise` — settles. If your handler takes 90 seconds and the schedule is `* * * * *`, the second fire is the first minute boundary _after_ the handler finishes, not 60 seconds after the first fire. Invocations never stack.

### Error handling

Errors match `setTimeout` semantics:

- A synchronous `throw` emits `process.on("uncaughtException")`.
- A rejected returned `Promise` emits `process.on("unhandledRejection")`.

Without a listener, the process exits with code `1`. With a listener, the job keeps running — it does not stop on the first failure.

```ts
process.on("unhandledRejection", err => log.error("cron failed:", err));

Bun.cron("* * * * *", async () => {
await mightThrow(); // logged and retried next minute
});
```

### `bun --hot`

Under `bun --hot`, all in-process cron jobs are stopped immediately before the module graph re-evaluates. Every `Bun.cron()` call still in your source then re-registers. Editing the schedule, editing the handler, or deleting the line entirely all take effect on save without leaking timers.

### The `CronJob` handle

```ts
using job = Bun.cron("0 * * * *", () => {});

job.cron; // => "0 * * * *"
job.stop(); // cancel — the handler will not fire again
job.unref(); // allow the process to exit even while scheduled
job.ref(); // keep the process alive (default)
```

`CronJob` is [`Disposable`](https://github.com/tc39/proposal-explicit-resource-management) — `using job = Bun.cron(...)` auto-stops at scope exit. `stop()`, `ref()`, and `unref()` all return the job for chaining.

### Fake timers

In-process cron is anchored to the real wall clock. `jest.useFakeTimers()`, `setSystemTime()`, `advanceTimersByTime()`, and `runAllTimers()` do not affect when it fires.

---

## `Bun.cron(path, schedule, title)` — OS-level

Register an OS-level cron job that runs a JavaScript/TypeScript module on a schedule.

Expand Down
225 changes: 190 additions & 35 deletions packages/bun-types/bun.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7382,47 +7382,202 @@ declare module "bun" {
| (string & {});

/**
* Register an OS-level cron job that runs a JavaScript/TypeScript module on a schedule.
*
* The module must export a `default` object with a `scheduled(controller)` method,
* conforming to the [Cloudflare Workers Cron Triggers API](https://developers.cloudflare.com/workers/runtime-apis/handlers/scheduled/).
*
* On Linux, registers with [crontab](https://man7.org/linux/man-pages/man5/crontab.5.html).
* On macOS, registers with [launchd](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html).
* On Windows, registers with [Task Scheduler](https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page).
*
* **Cron expression syntax** (5 fields: `minute hour day month weekday`):
*
* | Field | Values | Special |
* |-------|--------|---------|
* | Minute | `0-59` | `*` `,` `-` `/` |
* | Hour | `0-23` | `*` `,` `-` `/` |
* | Day of month | `1-31` | `*` `,` `-` `/` |
* | Month | `1-12` or `JAN-DEC` | `*` `,` `-` `/` |
* | Day of week | `0-7` or `SUN-SAT` | `*` `,` `-` `/` |
*
* - `0` and `7` both mean Sunday in the weekday field.
* - Month/day names are case-insensitive (`MON`, `Mon`, `Monday` all work).
* - Predefined nicknames: `@yearly`, `@annually`, `@monthly`, `@weekly`, `@daily`, `@midnight`, `@hourly`.
* - When both day-of-month and day-of-week are specified (neither is `*`),
* the job runs when **either** field matches ([POSIX cron](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html) behavior).
*
* @param path - Path to the script to run (resolved relative to caller)
* @param schedule - Cron expression or predefined nickname (e.g. `"30 2 * * MON"`, `"@daily"`)
* @param title - Unique identifier for this cron job (alphanumeric, hyphens, underscores only)
* @returns Promise that resolves when the cron job is registered
* @throws If the expression is invalid, the title contains invalid characters, or registration fails
* A handle to an in-process cron job returned by {@link Bun.cron} when called with a callback.
*
* @example
* ```ts
* // Run every Monday at 2:30 AM
* await Bun.cron("./worker.ts", "30 2 * * MON", "weekly-report");
*
* // Run daily at midnight
* await Bun.cron("./cleanup.ts", "@daily", "daily-cleanup");
* const job = Bun.cron("0 * * * *", async () => {
* await cleanupTempFiles();
* });
* // Later:
* job.stop();
* ```
*/
interface CronJob extends Disposable {
/** The cron expression string. */
readonly cron: string;
/** Cancel this cron job. The callback will not fire again. */
stop(): CronJob;
/** Keep the process alive while this job is scheduled (default). */
ref(): CronJob;
/** Allow the process to exit even while this job is scheduled. */
unref(): CronJob;
}

const cron: {
/**
* Schedule an **in-process** cron job that calls a function on a schedule.
*
* Unlike the module-path overload, this runs the callback on the current event loop —
* the job dies with the process and does not survive reboots. State is shared between
* invocations (closures, module-level variables, database connections all persist).
*
* | | In-process (this overload) | OS-level (path + title) |
* |---|---|---|
* | Survives process exit | No | Yes |
* | Shared state between runs | Yes | No (fresh process each time) |
* | Windows expression limits | None | 48-trigger cap |
* | Return type | {@link CronJob} (sync) | `Promise<void>` |
*
* ### No-overlap guarantee
*
* The next fire time is computed only after the callback settles (including any returned
* Promise). If your callback takes 3 minutes and runs every minute, it fires at T+0 → runs
* until T+3 → next fire is the first minute boundary after T+3. Invocations never stack.
*
* ### Error semantics
*
* Matches `setTimeout`: a synchronous throw emits `uncaughtException`, a rejected Promise
* emits `unhandledRejection`. Without a listener, the process exits with code 1. The job
* reschedules itself after an error — it does not stop on first failure.
*
* ```ts
* process.on("unhandledRejection", (err) => log.error(err)); // keep going
* Bun.cron("* * * * *", async () => { await mightThrow(); });
* ```
Comment thread
alii marked this conversation as resolved.
Resolved
*
* ### Cron expression syntax
*
* Five fields: `minute hour day-of-month month day-of-week`.
*
* | Field | Values | Special chars |
* |-------|--------|---------------|
* | Minute | `0-59` | `*` `,` `-` `/` |
* | Hour | `0-23` | `*` `,` `-` `/` |
* | Day of month | `1-31` | `*` `,` `-` `/` |
* | Month | `1-12` or `JAN`-`DEC` | `*` `,` `-` `/` |
* | Day of week | `0-7` or `SUN`-`SAT` | `*` `,` `-` `/` |
*
* - `0` and `7` both mean Sunday.
* - Month and weekday names are case-insensitive 3-letter abbreviations.
Comment thread
alii marked this conversation as resolved.
Resolved
* - Nicknames: `@yearly`, `@annually`, `@monthly`, `@weekly`, `@daily`, `@midnight`, `@hourly`.
* - When both day-of-month and day-of-week are restricted (neither is `*`), the job
* fires when **either** matches — [POSIX cron](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html) OR semantics.
* - All expressions work on all platforms — there is no Windows trigger limit here.
*
* ### Lifecycle & `--hot`
*
* Under `bun --hot`, all in-process cron jobs are stopped immediately before the module
* graph is re-evaluated. Each `Bun.cron()` call still in your source then re-registers,
* so editing the schedule, editing the callback, or **deleting the line entirely** all
* take effect on save without leaking timers.
*
* By default the job keeps the process alive (like `setInterval`); call `.unref()` to let
* the process exit naturally when nothing else is pending.
*
* @param schedule Cron expression or nickname (e.g. `"*\/5 * * * *"`, `"@hourly"`).
* @param handler Function to call on each fire. May return a Promise — the next fire
* is not scheduled until it settles.
* @returns A {@link CronJob} handle. Chainable: `.stop()`, `.ref()`, `.unref()` all
* return the job itself.
* @throws Synchronously if `schedule` is invalid, or the expression has no future
* occurrences (e.g. `"0 0 30 2 *"` — February 30th).
*
* @example
* ```ts
* // Hourly cleanup, keeps process alive
* Bun.cron("0 * * * *", async () => {
* await cleanupTempFiles();
* });
*
* // Background healthcheck that doesn't block process exit
* Bun.cron("*\/30 * * * *", () => fetch("https://example.com/health")).unref();
*
* // Stop conditionally
* const job = Bun.cron("* * * * *", async () => {
* if (await isDone()) job.stop();
* });
* ```
*
* @see {@link CronJob} for the returned handle.
* @see {@link Bun.cron.parse} to preview the next fire time.
*/
(schedule: CronWithAutocomplete, handler: (this: CronJob) => MaybePromise<void>): CronJob;
/**
* Register an **OS-level** cron job that runs a JavaScript/TypeScript module on a schedule.
*
* Unlike the callback overload, this registers the job with the operating system's
* scheduler — the job survives process exit and persists across reboots. Bun spawns
* a fresh process for each invocation, so there is no shared state between runs.
*
* | Platform | Scheduler | Inspect with |
* |----------|-----------|--------------|
* | Linux | [crontab](https://man7.org/linux/man-pages/man5/crontab.5.html) | `crontab -l` |
* | macOS | [launchd](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html) | `launchctl list` |
* | Windows | [Task Scheduler](https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page) | `schtasks /query` |
*
* ### Module shape
*
* The target module must have a `default` export with a `scheduled(controller)` method,
* matching the [Cloudflare Workers Cron Triggers](https://developers.cloudflare.com/workers/runtime-apis/handlers/scheduled/)
* API. The controller exposes `cron` (the expression) and `scheduledTime` (ms since epoch).
*
* ```ts
* // worker.ts
* export default {
* async scheduled(controller: Bun.CronController) {
* console.log(`Fired: ${controller.cron} at ${new Date(controller.scheduledTime)}`);
* await doWork();
* },
* };
* ```
*
* ### Cron expression syntax
*
* Five fields: `minute hour day-of-month month day-of-week`.
*
* | Field | Values | Special chars |
* |-------|--------|---------------|
* | Minute | `0-59` | `*` `,` `-` `/` |
* | Hour | `0-23` | `*` `,` `-` `/` |
* | Day of month | `1-31` | `*` `,` `-` `/` |
* | Month | `1-12` or `JAN`-`DEC` | `*` `,` `-` `/` |
* | Day of week | `0-7` or `SUN`-`SAT` | `*` `,` `-` `/` |
*
* - `0` and `7` both mean Sunday.
* - Month and weekday names are case-insensitive 3-letter abbreviations.
* - Nicknames: `@yearly`, `@annually`, `@monthly`, `@weekly`, `@daily`, `@midnight`, `@hourly`.
* - When both day-of-month and day-of-week are restricted (neither is `*`), the job
* fires when **either** matches — [POSIX cron](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html) OR semantics.
*
* ### Platform caveats
*
* - **Windows:** minute steps that don't evenly divide 60 (e.g. `*\/7`, `*\/11`) with
* all hours active exceed Task Scheduler's 48-trigger limit and throw. Divisors
* of 60 (`*\/5`, `*\/10`, `*\/15`, `*\/20`, `*\/30`) and all common patterns work.
* - **Windows headless/CI:** registration fails if the current user's SID can't be
* resolved (typical under service accounts). Run as a regular user or create the
* task manually with `schtasks /create /ru SYSTEM`.
* - **macOS:** stdout/stderr are written to `/tmp/bun.cron.<title>.{stdout,stderr}.log`.
*
* ### Idempotency & removal
*
* Registering with a title that already exists replaces the previous entry. Use
* {@link Bun.cron.remove} to unregister. The title is namespaced per user, so
* different users can register jobs with the same title independently.
*
* @param path Path to the module to run. Resolved relative to the calling file.
* @param schedule Cron expression or nickname (e.g. `"30 2 * * MON"`, `"@daily"`).
* @param title Unique identifier for this job. Alphanumeric, hyphens, and underscores only —
* used directly in crontab markers, launchd service labels, and schtasks task names.
* @returns Promise that resolves once the OS scheduler has accepted the job.
* @throws If the cron expression is invalid, `title` contains illegal characters,
* the expression exceeds Windows' trigger limit, or the underlying scheduler command fails
* (the error message includes the scheduler's stderr output).
*
* @example
* ```ts
* // Register once (e.g. in a postinstall script or setup command)
* await Bun.cron("./jobs/weekly-report.ts", "30 2 * * MON", "weekly-report");
* await Bun.cron("./jobs/cleanup.ts", "@daily", "daily-cleanup");
*
* // Later, to unregister:
* await Bun.cron.remove("weekly-report");
* ```
*
* @see {@link Bun.cron.remove} to unregister.
* @see {@link Bun.cron.parse} to preview the next fire time.
*/
(path: string, schedule: CronWithAutocomplete, title: string): Promise<void>;
/**
* Remove a previously registered cron job by its title.
Expand Down
1 change: 1 addition & 0 deletions src/bun.js/VirtualMachine.zig
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@ pub fn reload(this: *VirtualMachine, _: *HotReloader.Task) void {
Output.enableBuffering();
}

jsc.API.cron.CronJob.clearAllForVM(this);
this.global.reload() catch @panic("Failed to reload");
this.hot_reload_counter += 1;
this.pending_internal_promise = this.reloadEntryPoint(this.main) catch @panic("Failed to reload");
Comment thread
claude[bot] marked this conversation as resolved.
Resolved
Comment thread
alii marked this conversation as resolved.
Resolved
Expand Down
1 change: 1 addition & 0 deletions src/bun.js/api.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub const TLSSocket = @import("./api/bun/socket.zig").TLSSocket;
pub const SocketHandlers = @import("./api/bun/socket.zig").Handlers;

pub const Subprocess = @import("./api/bun/subprocess.zig");
pub const cron = @import("./api/cron.zig");
pub const Terminal = @import("./api/bun/Terminal.zig");
pub const WebViewHostProcess = @import("./webview/HostProcess.zig");
pub const ChromeProcess = @import("./webview/ChromeProcess.zig");
Expand Down
7 changes: 7 additions & 0 deletions src/bun.js/api/Timer/EventLoopTimer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub const Tag = enum {
DateHeaderTimer,
BunTest,
EventLoopDelayMonitor,
CronJob,

pub fn Type(comptime T: Tag) type {
return switch (T) {
Expand All @@ -95,6 +96,7 @@ pub const Tag = enum {
.DateHeaderTimer => jsc.API.Timer.DateHeaderTimer,
.BunTest => jsc.Jest.bun_test.BunTest,
.EventLoopDelayMonitor => jsc.API.Timer.EventLoopDelayMonitor,
.CronJob => bun.api.cron.CronJob,
};
}

Comment thread
alii marked this conversation as resolved.
Resolved
Expand All @@ -104,6 +106,7 @@ pub const Tag = enum {
.BunTest, // for test timeouts
.EventLoopDelayMonitor, // probably important
.StatWatcherScheduler,
.CronJob, // calendar-anchored to real wall clock
=> false,
else => true,
};
Expand Down Expand Up @@ -191,6 +194,10 @@ pub fn fire(self: *Self, now: *const timespec, vm: *VirtualMachine) void {
const monitor = @as(*jsc.API.Timer.EventLoopDelayMonitor, @fieldParentPtr("event_loop_timer", self));
monitor.onFire(vm, now);
},
.CronJob => {
const job = @as(*bun.api.cron.CronJob, @fieldParentPtr("event_loop_timer", self));
job.onTimerFire(vm);
},
inline else => |t| {
if (@FieldType(t.Type(), "event_loop_timer") != Self) {
@compileError(@typeName(t.Type()) ++ " has wrong type for 'event_loop_timer'");
Expand Down
Loading
Loading