anomalyco/sst · error · VisibleError
Cannot access `nodes.loadBalancer` in dev mode.
Error message
Cannot access `nodes.loadBalancer` in dev mode.
What it means
`nodes.loadBalancer` returns the Elastic Load Balancer created when the Service exposes public ports. In dev mode the load balancer resource is not created (dev traffic is routed directly to the dev process), so the getter throws this VisibleError before the unrelated no-public-ports check can even run.
Source
Thrown at platform/src/components/aws/service.ts:2908
* The Amazon ECS Task Role.
*/
taskRole: this.taskRole,
/**
* The Amazon ECS Task Definition.
*/
get taskDefinition() {
if (self.dev)
throw new VisibleError(
"Cannot access `nodes.taskDefinition` in dev mode.",
);
return self.taskDefinition!;
},
/**
* The Amazon Elastic Load Balancer.
*/
get loadBalancer() {
if (self.dev)
throw new VisibleError(
"Cannot access `nodes.loadBalancer` in dev mode.",
);
if (!self.loadBalancer)
throw new VisibleError(
"Cannot access `nodes.loadBalancer` when no public ports are exposed.",
);
return self.loadBalancer;
},
/**
* The Amazon Application Auto Scaling target.
*/
get autoScalingTarget() {
if (self.dev)
throw new VisibleError(
"Cannot access `nodes.autoScalingTarget` in dev mode.",
);
return self.autoScalingTarget!;
},View on GitHub (pinned to a0bd20f762)
Solutions
- Guard the access with `$dev` from `sst/dev` and skip load-balancer wiring in dev mode.
- If you actually intended deploy-only work, run `sst deploy` instead of `sst dev`.
- Remember dev mode also implies the second check (`no public ports`) never applies; handle both conditions in dev-safe code.
Example fix
// before
const lb = service.nodes.loadBalancer;
// after
import { $dev } from "sst/dev";
const lb = $dev ? undefined : service.nodes.loadBalancer; Defensive patterns
Strategy: validation
Validate before calling
import { $dev } from "sst/dev";
if (!$dev) {
const lb = service.nodes.loadBalancer; // also requires public ports configured
} Type guard
import { $dev } from "sst/dev";
const hasLoadBalancer = (): boolean => !$dev; Try / catch
try {
const lb = service.nodes.loadBalancer;
} catch (e) {
if (String(e).includes("nodes.loadBalancer")) {
// fallback: no ALB in dev / no public ports
} else throw e;
} Prevention
- Only reference `nodes.loadBalancer` when the Service config sets a load balancer with public ports.
- Branch on `$dev` before accessing ALB-related nodes.
- Keep load-balancer wiring in deploy-only code paths.
When it happens
Trigger: Reading `service.nodes.loadBalancer` while `sst dev` is active on a Service component, regardless of whether `loadBalancer`/public ports are configured.
Common situations: Adding a listener rule, target group, or custom DNS record that references the service's load balancer; code tested with `sst deploy` then run under `sst dev` for local iteration.
Related errors
- Cannot access `nodes.taskDefinition` in dev mode.
- Cannot access `nodes.autoScalingTarget` in dev mode.
- Cannot access `nodes.cluster` in dev mode.
- 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/802164c22fe1c4d6.
Report an issue: GitHub.