anomalyco/sst · error · VisibleError
No function created for the "${self._name}" cron job.
Error message
No function created for the "${self._name}" cron job. What it means
The deprecated `cron.nodes.job` getter returns the Lambda Function node, but it is only available when the cron was actually created with a function target. When the CronV2 was created with a `task` (or no function), accessing `job` throws this VisibleError instead of returning undefined.
Source
Thrown at platform/src/components/aws/cron-v2.ts:526
{ parent },
),
);
}
}
/**
* The underlying [resources](/docs/components/#nodes) this component creates.
*/
public get nodes() {
const self = this;
return {
/**
* The AWS Lambda Function that'll be invoked when the cron job runs.
* @deprecated Use `nodes.function` instead.
*/
get job() {
if (!self.fn)
throw new VisibleError(
`No function created for the "${self._name}" cron job.`,
);
return self.fn.apply((fn) => fn.getFunction());
},
/**
* The AWS Lambda Function that'll be invoked when the cron job runs.
*/
get function() {
if (!self.fn)
throw new VisibleError(
`No function created for the "${self._name}" cron job.`,
);
return self.fn.apply((fn) => fn.getFunction());
},
/**
* The EventBridge Scheduler Schedule resource.
*/
schedule: this._schedule,View on GitHub (pinned to a0bd20f762)
Solutions
- Use `nodes.function` instead of the deprecated `nodes.job`
- Guard by checking that the cron was created with a `function` before accessing the node
- If the cron is task-based, access the task resources instead of the function node
Example fix
// before const fn = cron.nodes.job; // after const fn = cron.nodes.function; // when the cron has a function target
Defensive patterns
Strategy: type-guard
Validate before calling
const fn = cronArgs.function ? cron.nodes.job : undefined;
Type guard
function hasFunctionNode(cron: sst.aws.CronV2, args: sst.aws.CronV2Args): boolean {
return Boolean(args.function || args.job);
} Try / catch
let fn;
try {
fn = cron.nodes.job;
} catch (e) {
if (e instanceof Error && e.message.includes("No function created")) {
fn = undefined; // task-based cron
} else throw e;
} Prevention
- Prefer `nodes.function` over the deprecated `nodes.job`
- Remember task-based crons have no function node
- Branch on how the cron was constructed before accessing nodes
When it happens
Trigger: Accessing `cron.nodes.job` on a CronV2 instance created with `task` or with no function target at all.
Common situations: Legacy code still referencing the deprecated `nodes.job` accessor after switching the cron to an ECS task; generic code that iterates crons and assumes every cron has a function.
Related errors
- No function created for the "${self.name}" cron job.
- You cannot provide both "job" and "function" in the "${name}
- You cannot provide both "job" and "function" in the "${name}
- You cannot provide both "job" and "worker" in the "${name}"
- You must provide a KMS key via `kmsKey` when configuring `cu
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/8efae4d693986fde.
Report an issue: GitHub.