{"record":{"id":"2c7603dc79a6998e","repo":"gatsbyjs/gatsby","slug":"previous-build-used-unsafe-builtin-method-we-need","errorCode":null,"errorMessage":"Previous build used unsafe builtin method. We need to rebuild all pages","messagePattern":"Previous build used unsafe builtin method\\. We need to rebuild all pages","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/commands/build-utils.ts","lineNumber":153,"sourceCode":"        }\n      }\n    }\n\n    if (!previousAction || overwritePreviousAction) {\n      normalizedPagePathToAction.set(normalizedPagePath, {\n        actualPath: path,\n        action,\n      })\n      if (action === `delete`) {\n        toDelete.add(path)\n      } else if (action === `regenerate`) {\n        toRegenerate.add(path)\n      }\n    }\n  }\n\n  if (state.html.unsafeBuiltinWasUsedInSSR) {\n    reporter.warn(\n      `Previous build used unsafe builtin method. We need to rebuild all pages`\n    )\n  }\n\n  state.html.trackedHtmlFiles.forEach(function (htmlFile, path) {\n    const page = state.pages.get(path)\n    if (htmlFile.isDeleted || !page) {\n      // FIXME: checking pages state here because pages are not persisted\n      // and because of that `isDeleted` might not be set ...\n      markActionForPage(path, `delete`)\n    } else {\n      if (getPageMode(page, state) === `SSG`) {\n        if (htmlFile.dirty || state.html.unsafeBuiltinWasUsedInSSR) {\n          markActionForPage(path, `regenerate`)\n        } else {\n          markActionForPage(path, `reuse`)\n        }\n      }","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/e85d62f1779e353eaac1753211629a26d123e26c/packages/gatsby/src/commands/build-utils.ts#L135-L171","documentation":"In calcDirtyHtmlFiles, when state.html.unsafeBuiltinWasUsedInSSR is true (a previous build's SSR run touched unsafe globals), Gatsby warns that it cannot trust the incremental HTML cache and must regenerate every page rather than only dirty ones. This is a cache-invalidation notice, not a thrown failure.","triggerScenarios":"Thrown at packages/gatsby/src/commands/build-utils.ts:153 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Eliminate the unsafe builtin usage reported in the prior build so the flag is never set","Accept the one-time full rebuild; subsequent builds will be incremental again","Audit SSR code paths (wrapPageElement, ssr rendering) for window/document access"],"exampleFix":null,"handlingStrategy":"fallback","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"}