{"record":{"id":"3a45586ecd8d4fe3","repo":"anomalyco/sst","slug":"cannot-access-nodes-cluster-in-dev-mode","errorCode":null,"errorMessage":"Cannot access `nodes.cluster` in dev mode.","messagePattern":"Cannot access `nodes\\.cluster` in dev mode\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/redis-v1.ts","lineNumber":508,"sourceCode":"  /**\n   * The port to connect to the Redis cluster.\n   */\n  public get port() {\n    return this.dev ? this.dev.port : this.cluster!.port.apply((v) => v!);\n  }\n\n  /**\n   * The underlying [resources](/docs/components/#nodes) this component creates.\n   */\n  public get nodes() {\n    const _this = this;\n    return {\n      /**\n       * The ElastiCache Redis cluster.\n       */\n      get cluster() {\n        if (_this.dev)\n          throw new VisibleError(\"Cannot access `nodes.cluster` in dev mode.\");\n        return _this.cluster!;\n      },\n    };\n  }\n\n  /** @internal */\n  public getSSTLink() {\n    return {\n      properties: {\n        host: this.host,\n        port: this.port,\n        username: this.username,\n        password: this.password,\n      },\n    };\n  }\n\n  /**","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/redis-v1.ts#L490-L526","documentation":"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.","triggerScenarios":"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.","commonSituations":"Sharing a resource function that reads nodes.cluster across dev and prod; scripts or Pulumi expressions accessing the cluster in a dev link context.","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"],"exampleFix":"// before\nconst host = redis.nodes.cluster.cacheNodes[0].host;\n// after\nconst host = $dev\n  ? redis.nodes.dev.host\n  : redis.nodes.cluster.cacheNodes[0].host;","handlingStrategy":"validation","validationCode":"if ($dev) {\n  if (typeof cluster !== \"undefined\") throw new Error(\"Use nodes.dev in dev mode, not nodes.cluster\");\n}\nconst host = $dev ? redis.nodes.dev.host : redis.nodes.cluster.cacheNodes[0].host;","typeGuard":"function canAccessCluster(redis: sst.aws.Redis): boolean {\n  return !redis.dev?.enabled;\n}","tryCatchPattern":"try {\n  const cluster = redis.nodes.cluster;\n} catch (e) {\n  if (String(e).includes(\"dev mode\")) console.error(\"Use redis.nodes.dev in dev mode\");\n  throw e;\n}","preventionTips":["Branch on $dev before touching nodes.cluster","Use nodes.dev for local Redis endpoints in dev","Keep cluster access in prod-only code paths"],"tags":["redis","elasticache","dev-mode"],"backgroundTag":"resource-unavailable-in-dev","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}