anomalyco/sst · error · VisibleError

Cannot access `nodes.cluster` in dev mode.

Error message

Cannot access `nodes.cluster` in dev mode.

What it means

In SST dev mode, the Redis component does not create a real ElastiCache Redis cluster (sst dev runs the app locally without provisioning it). Accessing the `nodes.cluster` getter would return undefined, so SST throws a VisibleError telling you this node is unavailable in dev mode.

Source

Thrown at platform/src/components/aws/redis.ts:662

  /**
   * The port to connect to the Redis cluster.
   */
  public get port() {
    return this.dev ? this.dev.port : this.cluster!.port.apply((v) => v!);
  }

  /**
   * The underlying [resources](/docs/components/#nodes) this component creates.
   */
  public get nodes() {
    const _this = this;
    return {
      /**
       * The ElastiCache Redis cluster.
       */
      get cluster() {
        if (_this.dev)
          throw new VisibleError("Cannot access `nodes.cluster` in dev mode.");
        return _this.cluster!;
      },
    };
  }

  /** @internal */
  public getSSTLink() {
    return {
      properties: {
        host: this.host,
        port: this.port,
        username: this.username,
        password: this.password,
      },
    };
  }

  /**

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Guard the access with the component's `dev` flag and use a fallback (e.g. an environment-provided local Redis URL) in dev mode
  2. Move `nodes.cluster` access behind `if (!app.local)` / `if (!$app.local)` checks or into a `sst deploy`-only path
  3. Use `redis.url` or the link data instead of the raw cluster node, which handles dev mode gracefully
  4. Test the Infra change with `sst deploy --stage <stage>` instead of dev mode when you need cluster properties

Example fix

// before
const sg = redis.nodes.cluster.nodes.securityGroups[0];
// after
const sg = redis.dev
  ? undefined
  : redis.nodes.cluster.nodes.securityGroups[0];
Defensive patterns

Strategy: validation

Validate before calling

if (!redis.dev) {
  const cluster = redis.nodes.cluster; // safe
}
// in dev, use local redis URL instead

Type guard

function clusterAvailable(r: { dev: boolean }): boolean {
  return !r.dev;
}

Try / catch

try {
  cluster = redis.nodes.cluster;
} catch (e) {
  cluster = null; // fall back to local dev redis
}

Prevention

When it happens

Trigger: Accessing `redis.nodes.cluster` while running `sst dev` (i.e. the `dev` flag on the component is true and the ElastiCache cluster was never created).

Common situations: Reading cluster properties (endpoint, ARN, security groups) in an Infra config that works in `sst deploy` but crashes during `sst dev`; referencing nodes.cluster inside shared code executed in both modes.

Related errors


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