Skip to content
Docs

Command palette

Jump to a page or view, or find a todo by name.

Changelog

Scheduled jobs

One cron tick settles six concurrent jobs, then indexes Document Text within the same deadline and scoped pool.

Markdown

What runs

The Worker scheduled handler calls runScheduledJobs on the one-minute cron. The program runs audits, imports, upload recovery, webhooks, billing and push concurrently. A typed failure or defect in one job does not interrupt its siblings. After these jobs settle, document maintenance and indexing run with their own 15-second budget inside the remaining global deadline. Indexing processes one document per tick; larger backlogs need multiple ticks. Failures become a single scheduled execution error identifying the failed jobs.

Document conversion runs in a browser Web Worker. Cron validates and indexes submitted Markdown; it does not run AnyDoc. ADR-0008 records the memory evidence behind this ordering and the 192 KiB text cap. A global timeout before the earlier jobs settle skips document work.

The tick acquires one job pool in an Effect scope. Its 25-second deadline interrupts work; fetch cancellation and drained database promises settle before the pool closes. An interrupted summary has empty counters, while durable rows and traces retain completed work.

Run locally

pnpm jobs:run
# Production-runtime recovery and network-fault verification:
node scripts/test-local-postgres.mjs exec node scripts/test-local-jobs.mjs

The CLI uses the configured database. Use the disposable wrapper for tests. The workerd harness calls /cdn-cgi/handler/scheduled with --test-scheduled and uses a local R2 fixture and TCP fault proxy. It verifies replay and connection cleanup, not Cloudflare's production scheduling latency.

Add a job

Return an Effect from the new job, register it in the composed program and summary, and use the scoped database passed to it. Model durable admission, claim ownership, replay and terminal failure before adding retry. Keep external write attempts idempotent where possible; do not add in-round retries to sends.

Test deadlines with @effect/vitest and TestClock using production values. Changes to queue persistence or deadlines must repeat the fault tests in ADR-0006.

Key files

Edit on GitHubDocumentation is in English.