anomalyco/sst · error · VisibleError
Cannot access `nodes.cluster` in dev mode.
Error message
Cannot access `nodes.cluster` in dev mode.
What it means
The Redis v1 component's nodes.cluster getter exposes the real ElastiCache cluster, which does not exist in dev mode (a local Redis is used instead). Accessing it while dev is enabled throws this VisibleError.
Source
Thrown at platform/src/components/aws/redis-v1.ts:508
/**
* 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 access with the dev flag before reading nodes.cluster
- In dev, use nodes.dev (the local Redis endpoint) instead
- Remove nodes.cluster usage from code paths that run in dev
Example fix
// before const host = redis.nodes.cluster.cacheNodes[0].host; // after const host = $dev ? redis.nodes.dev.host : redis.nodes.cluster.cacheNodes[0].host;
Defensive patterns
Strategy: validation
Validate before calling
if ($dev) {
if (typeof cluster !== "undefined") throw new Error("Use nodes.dev in dev mode, not nodes.cluster");
}
const host = $dev ? redis.nodes.dev.host : redis.nodes.cluster.cacheNodes[0].host; Type guard
function canAccessCluster(redis: sst.aws.Redis): boolean {
return !redis.dev?.enabled;
} Try / catch
try {
const cluster = redis.nodes.cluster;
} catch (e) {
if (String(e).includes("dev mode")) console.error("Use redis.nodes.dev in dev mode");
throw e;
} Prevention
- Branch on $dev before touching nodes.cluster
- Use nodes.dev for local Redis endpoints in dev
- Keep cluster access in prod-only code paths
When it happens
Trigger: Reading redis.nodes.cluster (or typing `sst shell` code that touches it) on a Redis component with dev enabled, e.g. while `sst dev` is running.
Common situations: Sharing a resource function that reads nodes.cluster across dev and prod; scripts or Pulumi expressions accessing the cluster in a dev link context.
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}".
- You must provide the password to connect to your locally run
- You must provide the password to connect to your locally run
AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30).
Data as JSON: /api/errors/3a45586ecd8d4fe3.
Report an issue: GitHub.