{"record":{"id":"7fdd240493f301b7","repo":"anomalyco/sst","slug":"cannot-access-nodes-service-in-dev-mode","errorCode":null,"errorMessage":"Cannot access `nodes.service` in dev mode.","messagePattern":"Cannot access `nodes\\.service` in dev mode\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/service-v1.ts","lineNumber":810,"sourceCode":"      return this.devUrl;\n    }\n\n    if (!this._url) throw new VisibleError(errorMessage);\n    return this._url;\n  }\n\n  /**\n   * The underlying [resources](/docs/components/#nodes) this component creates.\n   */\n  public get nodes() {\n    const self = this;\n    return {\n      /**\n       * The Amazon ECS Service.\n       */\n      get service() {\n        if ($dev)\n          throw new VisibleError(\"Cannot access `nodes.service` in dev mode.\");\n        return self.service!;\n      },\n      /**\n       * The Amazon ECS Task Role.\n       */\n      get taskRole() {\n        return self.taskRole;\n      },\n      /**\n       * The Amazon ECS Task Definition.\n       */\n      get taskDefinition() {\n        if ($dev)\n          throw new VisibleError(\n            \"Cannot access `nodes.taskDefinition` in dev mode.\",\n          );\n        return self.taskDefinition!;\n      },","sourceCodeStart":792,"sourceCodeEnd":828,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/service-v1.ts#L792-L828","documentation":"In SST's `Service` (v1) component, the `nodes` accessor object exposes raw Pulumi resources. During `sst dev`, the service runs as a live Lambda/container and the underlying `ecs.Service` Pulumi resource is not created, so `nodes.service` would be `undefined`. SST throws this `VisibleError` up front to give a clear message instead of a cryptic null dereference.","triggerScenarios":"Calling `service.nodes.service` while running `sst dev` (i.e. `$dev` is true). Any code path that reads the ECS Service resource from the nodes getter during the dev loop triggers it.","commonSituations":"Developers wiring an ECS Service to another component (e.g. granting IAM permissions or referencing the service ARN) in code that also runs during dev mode; following examples/docs that use `nodes` without dev-mode guards.","solutions":["Wrap the `nodes.service` access in `if (!$dev) { ... }` so it only runs on deploy.","Use the dev-mode alternatives the component provides (e.g. dev URL from `service.url`) instead of the raw resource.","Split infrastructure references into a module only imported/executed at deploy time.","If the reference is genuinely needed in dev, run `sst deploy --stage dev` instead of `sst dev` for that stack."],"exampleFix":"// before\nconst svc = myService.nodes.service;\nsvc.name.apply((n) => grantAccess(n));\n\n// after\nif (!$dev) {\n  const svc = myService.nodes.service;\n  svc.name.apply((n) => grantAccess(n));\n}","handlingStrategy":"validation","validationCode":"if ($dev) {\n  // skip nodes.service usage in dev\n} else {\n  const svc = myService.nodes.service;\n}","typeGuard":"function canAccessNodes<T>(component: T): boolean {\n  return !($dev as boolean);\n}","tryCatchPattern":"try {\n  const svc = myService.nodes.service;\n} catch (e) {\n  if (e instanceof VisibleError && e.message.includes(\"dev mode\")) return null;\n  throw e;\n}","preventionTips":["Always wrap `nodes.*` accesses in `if (!$dev)` checks.","Prefer component-level APIs (`service.url`) over raw Pulumi nodes.","Centralize deploy-only wiring in helper functions that assert non-dev."],"tags":["aws","ecs","dev-mode","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"}