{"record":{"id":"60f9786eb6b96ef1","repo":"anomalyco/sst","slug":"cannot-access-nodes-autoscalingtarget-in-dev-mod","errorCode":null,"errorMessage":"Cannot access `nodes.autoScalingTarget` in dev mode.","messagePattern":"Cannot access `nodes\\.autoScalingTarget` in dev mode\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/service.ts","lineNumber":2922,"sourceCode":"       * The Amazon Elastic Load Balancer.\n       */\n      get loadBalancer() {\n        if (self.dev)\n          throw new VisibleError(\n            \"Cannot access `nodes.loadBalancer` in dev mode.\",\n          );\n        if (!self.loadBalancer)\n          throw new VisibleError(\n            \"Cannot access `nodes.loadBalancer` when no public ports are exposed.\",\n          );\n        return self.loadBalancer;\n      },\n      /**\n       * The Amazon Application Auto Scaling target.\n       */\n      get autoScalingTarget() {\n        if (self.dev)\n          throw new VisibleError(\n            \"Cannot access `nodes.autoScalingTarget` in dev mode.\",\n          );\n        return self.autoScalingTarget!;\n      },\n      /**\n       * The Amazon Cloud Map service.\n       */\n      get cloudmapService() {\n        if (self.dev)\n          throw new VisibleError(\n            \"Cannot access `nodes.cloudmapService` in dev mode.\",\n          );\n\n        return output(self.cloudmapService).apply((service) => {\n          if (!service)\n            throw new VisibleError(\n              `Cannot access \"nodes.cloudmapService\" for the \"${self._name}\" Service. Cloud Map is not configured for the cluster.`,\n            );","sourceCodeStart":2904,"sourceCodeEnd":2940,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/service.ts#L2904-L2940","documentation":"`nodes.autoScalingTarget` exposes the Application Auto Scaling target, which only exists when autoscaling is configured on the Service. In dev mode the resource is not created at all, so the getter throws this VisibleError immediately instead of returning an undefined node.","triggerScenarios":"Reading `service.nodes.autoScalingTarget` while the app runs under `sst dev` (dev mode active), regardless of autoscaling configuration.","commonSituations":"Custom scaling policies or CloudWatch alarms that reference the scaling target; the code works on `sst deploy` but the developer hits the error when iterating locally with `sst dev`.","solutions":["Wrap the access in `$dev` from `sst/dev` and skip autoscaling-related wiring in dev mode.","Run `sst deploy` for workflows that need the actual Application Auto Scaling target resource.","If you also need autoscaling on deploy, additionally verify `scaling` args are set or the non-dev getter will fail on the non-null assertion."],"exampleFix":"// before\nconst target = service.nodes.autoScalingTarget;\n\n// after\nimport { $dev } from \"sst/dev\";\nconst target = $dev ? undefined : service.nodes.autoScalingTarget;","handlingStrategy":"validation","validationCode":"import { $dev } from \"sst/dev\";\nif (!$dev) {\n  const target = service.nodes.autoScalingTarget; // requires scaling configured on deploy\n}","typeGuard":"import { $dev } from \"sst/dev\";\nconst hasAutoScalingTarget = (): boolean => !$dev;","tryCatchPattern":"try {\n  const target = service.nodes.autoScalingTarget;\n} catch (e) {\n  if (String(e).includes(\"in dev mode\")) {\n    // skip autoscaling wiring in dev\n  } else throw e;\n}","preventionTips":["Gate autoscaling node access behind `$dev`.","Only reference the scaling target when the Service defines `scaling` args.","Validate infra code under `sst dev` regularly to catch environment-dependent access early."],"tags":["dev-mode","autoscaling","nodes","sst"],"backgroundTag":"resource-unavailable-in-dev-mode","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}