{"record":{"id":"9ab8b15a7a2e4b7c","repo":"gatsbyjs/gatsby","slug":"slices-are-disabled","errorCode":null,"errorMessage":"Slices are disabled.","messagePattern":"Slices are disabled\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/cache-dir/slice.js","lineNumber":64,"sourceCode":"\n      // just in case generating additional contextual information fails, we still want the base message to show\n      // and not show another cryptic error message\n      try {\n        additionalContextMessage = `\\n\\nSlice component \"${slicesContext.sliceRoot.name}\" (${slicesContext.sliceRoot.componentPath}) tried to render <Slice alias=\"${props.alias}\"/>`\n      } catch {\n        // don't need to handle it, we will just skip the additional context message if we fail to generate it\n      }\n\n      throw new Error(\n        `Nested slices are not supported.${additionalContextMessage}\\n\\nSee https://gatsbyjs.com/docs/reference/built-in-components/gatsby-slice#nested-slices`\n      )\n    } else {\n      throw new Error(\n        `Slice context \"${slicesContext.renderEnvironment}\" is not supported.`\n      )\n    }\n  } else {\n    throw new Error(`Slices are disabled.`)\n  }\n}\n\nclass SlicePropsError extends Error {\n  constructor(inBrowser, sliceName, propErrors, renderedByLocation) {\n    const errors = Object.entries(propErrors)\n      .map(\n        ([key, value]) =>\n          `not serializable \"${value}\" type passed to \"${key}\" prop`\n      )\n      .join(`, `)\n\n    const name = `SlicePropsError`\n    let stack = ``\n    let message = ``\n\n    if (inBrowser) {\n      let fullStack = ``","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/cache-dir/slice.js#L46-L82","documentation":"Thrown by the <Slice> component when process.env.GATSBY_SLICES is falsy at build/runtime. This environment variable gates the entire Slices feature; when it is not enabled, the <Slice> component refuses to render. This is the top-level feature gate — using <Slice> without enabling the feature always fails.","triggerScenarios":"A page or component renders <Slice alias='...' />, but the GATSBY_SLICES environment variable is not set (or set to a falsy value) during build. The Slice component's top-level if check fails and throws immediately.","commonSituations":"Developer copies a <Slice> usage from docs or another project without enabling the feature, the GATSBY_SLICES env var was set in one environment (local) but not another (CI/production), or the feature flag was removed in a Gatsby downgrade.","solutions":["Set GATSBY_SLICES=true in your environment (e.g. .env.development, .env.production, or CI environment variables) before building.","If you don't intend to use Slices, remove the <Slice> component usage from your code.","Ensure the env var is available at build time — Gatsby reads it during `gatsby build` / `gatsby develop`."],"exampleFix":"# before — GATSBY_SLICLES not set, using <Slice>\n# .env.development\n# (missing GATSBY_SLICES)\n\n# after\n# .env.development\nGATSBY_SLICES=true","handlingStrategy":"validation","validationCode":"// Check feature flag before using Slice\nfunction isSlicesEnabled() {\n  return process.env.GATSBY_SLICES === 'true' || process.env.GATSBY_SLICES === true\n}\n\nif (isSlicesEnabled()) {\n  // safe to use <Slice>\n} else {\n  console.warn('Slices are disabled. Set GATSBY_SLICES=true to enable.')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set GATSBY_SLICES=true in .env.development and .env.production if using Slices.","Document the feature flag requirement in your project README.","Remove <Slice> usage if the feature is not needed.","Verify the env var is set in CI before the build step."],"tags":["slices","feature-flag","environment-variables","configuration"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}