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 and throws this VisibleError when the Cron was not created with a function (e.g. it was created with an ECS `task` or no target), since `self.fn` is undefined.

Source

Thrown at platform/src/components/aws/cron.ts:406

          { 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 Rule resource.
       */
      rule: this.rule,

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Use `nodes.function` instead of the deprecated `nodes.job`
  2. Check that the cron was created with a `function` before accessing the node
  3. For task-based crons, use the task's resources instead

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.Cron, args: sst.aws.CronArgs): 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 Cron instance created with `task` or without a function target.

Common situations: Legacy code referencing the deprecated `nodes.job` accessor; shared helper functions that assume every cron has a Lambda function and try to add permissions or triggers.

Related errors


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