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
- Guard the access with the component's `dev` flag and use a fallback (e.g. an environment-provided local Redis URL) in dev mode
- Move `nodes.cluster` access behind `if (!app.local)` / `if (!$app.local)` checks or into a `sst deploy`-only path
- Use `redis.url` or the link data instead of the raw cluster node, which handles dev mode gracefully
- 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
- Always branch on the component's `dev` flag before touching raw node properties
- Prefer `redis.url`/link data over `nodes.cluster`
- Run `sst dev` early to catch dev-mode-incompatible code
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
- Cannot access `nodes.cluster` in dev mode.
- Failed to get auth token for Redis ${name}.
- Failed to lookup secret for Redis cluster "${name}".
- Cannot access `nodes.service` in dev mode.
- Cannot access `nodes.taskDefinition` in dev mode.
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/2e0a61cde70ec30a.
Report an issue: GitHub.