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

  1. Use `nodes.function` instead of the deprecated `nodes.job`
  2. Guard by checking that the cron was created with a `function` before accessing the node
  3. 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

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


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/8efae4d693986fde. Report an issue: GitHub.