{"record":{"id":"440f11080f968675","repo":"gatsbyjs/gatsby","slug":"unsafe-builtin-method-was-used-future-builds-will","errorCode":null,"errorMessage":"Unsafe builtin method was used, future builds will need to rebuild all pages","messagePattern":"Unsafe builtin method was used, future builds will need to rebuild all pages","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/commands/build-html.ts","lineNumber":465,"sourceCode":"      if (activity && activity.tick) {\n        activity.tick(pageSegment.length)\n      }\n    })\n  } catch (e) {\n    if (e?.context?.unsafeBuiltinsUsageByPagePath) {\n      for (const [_pagePath, arrayOfUsages] of Object.entries(\n        e.context.unsafeBuiltinsUsageByPagePath\n      )) {\n        // @ts-ignore TS doesn't know arrayOfUsages is Iterable\n        for (const unsafeUsageStack of arrayOfUsages) {\n          uniqueUnsafeBuiltinUsedStacks.add(unsafeUsageStack)\n        }\n      }\n    }\n    throw e\n  } finally {\n    if (uniqueUnsafeBuiltinUsedStacks.size > 0) {\n      console.warn(\n        `Unsafe builtin method was used, future builds will need to rebuild all pages`\n      )\n      store.dispatch({\n        type: `SSR_USED_UNSAFE_BUILTIN`,\n      })\n    }\n\n    for (const unsafeBuiltinUsedStack of uniqueUnsafeBuiltinUsedStacks) {\n      const prettyError = createErrorFromString(\n        unsafeBuiltinUsedStack,\n        `${htmlComponentRendererPath}.map`\n      )\n\n      const warningMessage = `${prettyError.stack}${\n        prettyError.codeFrame ? `\\n\\n${prettyError.codeFrame}\\n` : ``\n      }`\n\n      reporter.warn(warningMessage)","sourceCodeStart":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/e85d62f1779e353eaac1753211629a26d123e26c/packages/gatsby/src/commands/build-html.ts#L447-L483","documentation":"During HTML rendering (renderHTMLQueue), the SSR sandbox detected that page code used unsafe globals (e.g. window, document) during server-side rendering. Gatsby catches the error, records which page paths used which unsafe builtins, rethrows, and warns that all pages must be rebuilt next time because the incremental build cache for HTML is invalidated.","triggerScenarios":"Thrown at packages/gatsby/src/commands/build-html.ts:465 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Guard browser globals in components with typeof window !== `undefined` checks or the globalThis prefix","Move DOM-dependent code into useEffect or wrapSSR/replaceHydrateFunction-safe paths","Use Gatsby's SSR APIs or gatsby-plugin-less-unsafe-globals style fixes to avoid touching globals during SSR"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e85d62f1779e353eaac1753211629a26d123e26c","analyzedAt":"2026-08-26T17:50:09.662Z","contentChangedAt":"2026-08-26T17:50:09.662Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}