anomalyco/sst · error · VisibleError
You must provide a "worker" for the "${name}" Cron component
Error message
You must provide a "worker" for the "${name}" Cron component. What it means
The Cron component requires a handler definition, but after normalization neither `worker` nor the deprecated `job` was provided. SST cannot build a cron without something to run.
Source
Thrown at platform/src/components/cloudflare/cron.ts:164
const parent = this;
const workerArgs = normalizeWorker();
const worker = createWorker();
const trigger = createTrigger();
this.worker = worker;
this.trigger = trigger;
function normalizeWorker() {
if (args.job && args.worker)
throw new VisibleError(
`You cannot provide both "job" and "worker" in the "${name}" Cron component. The "job" property has been deprecated. Use "worker" instead.`,
);
return args.worker ?? args.job;
}
function createWorker() {
if (!workerArgs)
throw new VisibleError(
`You must provide a "worker" for the "${name}" Cron component.`,
);
return workerBuilder(`${name}Handler`, workerArgs, undefined, undefined, args.accountId);
}
function createTrigger() {
return all([args.schedules]).apply(([schedules]) => {
return new cloudflare.WorkersCronTrigger(
...transform(
args.transform?.trigger,
`${name}Trigger`,
{
accountId: args.accountId ?? DEFAULT_ACCOUNT_ID,
scriptName: worker.script.scriptName,
schedules: schedules.map((s) => ({ cron: s })),
},
{ parent },
),View on GitHub (pinned to a0bd20f762)
Solutions
- Add a `worker` property with the script/handler definition for the cron.
- Remove the Cron component entirely if no work is needed.
- Check that the args object passed to the component isn't conditionally dropping `worker`.
Example fix
// before
new sst.cloudflare.Cron(app, "Cron", { schedule: "0 * * * *" });
// after
new sst.cloudflare.Cron(app, "Cron", {
schedule: "0 * * * *",
worker: { scriptPath: "./src/cron.ts" },
}); Defensive patterns
Strategy: validation
Validate before calling
if (!cronArgs.worker && !cronArgs.job) throw new Error("Cron requires a 'worker' definition"); Type guard
const hasWorker = (a: { worker?: unknown }) => a.worker != null; Try / catch
try {
new sst.cloudflare.Cron(app, "Cron", cronArgs);
} catch (e) {
if (String(e).includes('must provide a "worker"')) console.error("Add a worker property to the Cron");
else throw e;
} Prevention
- Always pair `schedule` with a `worker` in Cron components.
- Watch for conditional args spreading that drops `worker`.
- Type the component args so `worker` is required.
When it happens
Trigger: Creating `new sst.cloudflare.Cron(app, "Cron", { schedule: ... })` with no `worker` (and no `job`) property; workerArgs is undefined in createWorker.
Common situations: Deleting the `job`/`worker` block during migration and leaving an empty component; conditional args that evaluate to undefined; copy-pasting a schedule-only example.
Related errors
- You cannot provide both "job" and "worker" in the "${name}"
- You must provide either a function or a task in the "${name}
- Found ${file} in "${path.resolve(sitePath)}" for ${component
- Could not find config file for ${componentName} in "${path.r
- Invalid worker definition for the "${name}" Worker
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/fb61337389208b79.
Report an issue: GitHub.