{"record":{"id":"222d3ad806acbf21","repo":"gatsbyjs/gatsby","slug":"the-size-of-at-least-one-page-context-chunk-exceed","errorCode":null,"errorMessage":"The size of at least one page context chunk exceeded 500kb, which could lead to degraded performance. Consider putting less data in the page context.","messagePattern":"The size of at least one page context chunk exceeded 500kb, which could lead to degraded performance\\. Consider putting less data in the page context\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/redux/persist.ts","lineNumber":122,"sourceCode":"): number {\n  // Pick a few random elements and measure their size then pick a chunk size\n  // ceiling based on the worst case. Each test takes time so there's trade-off.\n  // This attempts to prevent small sites with very large pages from OOMing.\n  // This heuristic could still fail if it randomly grabs the smallest nodes.\n  // TODO: test a few nodes per each type instead of from all nodes\n\n  const nodesToTest = 11 // Very arbitrary number\n  const valueCount = values.length\n  const step = Math.max(1, Math.ceil(valueCount / nodesToTest))\n  let maxSize = 0\n  for (let i = 0; i < valueCount; i += step) {\n    const size = v8.serialize(values[i]).length\n    maxSize = Math.max(size, maxSize)\n  }\n\n  // Sends a warning once if any of the chunkSizes exceeds approx 500kb limit\n  if (showMaxSizeWarning && maxSize > 500000) {\n    report.warn(\n      `The size of at least one page context chunk exceeded 500kb, which could lead to degraded performance. Consider putting less data in the page context.`\n    )\n  }\n\n  // Max size of a Buffer is 2gb (yeah, we're assuming 64bit system)\n  // https://stackoverflow.com/questions/8974375/whats-the-maximum-size-of-a-node-js-buffer\n  // Use 1.5gb as the target ceiling, allowing for some margin of error\n  return Math.floor((1.5 * 1024 * 1024 * 1024) / maxSize)\n}\n\nfunction prepareCacheFolder(\n  targetDir: string,\n  contents: DeepPartial<ICachedReduxState>\n): void {\n  // Temporarily save the nodes and pages and remove them from the main redux store\n  // This prevents an OOM when the page nodes collectively contain too much data\n  const nodesMap = contents.nodes\n  contents.nodes = undefined","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/e85d62f1779e353eaac1753211629a26d123e26c/packages/gatsby/src/redux/persist.ts#L104-L140","documentation":"Emitted from the LMDB persistence layer (near guessSafeChunkSize) when computing chunk sizes for redux persist: a sampled page-context chunk exceeded 500kb. Oversized contexts slow state hydration and persistence, so Gatsby warns that you're likely storing too much data in page context.","triggerScenarios":"Thrown at packages/gatsby/src/redux/persist.ts:122 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce data passed via createPage's context; query it in the page template instead","Store only IDs/scalars in context and resolve heavy data at render time","Recheck after trimming; the warning is heuristic and sampling-based"],"exampleFix":null,"handlingStrategy":"validation","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-14T00:17:10.932Z"}