gatsbyjs/gatsby · error
The size of at least one page context chunk exceeded 500kb,
Error message
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.
What it means
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.
Source
Thrown at packages/gatsby/src/redux/persist.ts:122
): number {
// Pick a few random elements and measure their size then pick a chunk size
// ceiling based on the worst case. Each test takes time so there's trade-off.
// This attempts to prevent small sites with very large pages from OOMing.
// This heuristic could still fail if it randomly grabs the smallest nodes.
// TODO: test a few nodes per each type instead of from all nodes
const nodesToTest = 11 // Very arbitrary number
const valueCount = values.length
const step = Math.max(1, Math.ceil(valueCount / nodesToTest))
let maxSize = 0
for (let i = 0; i < valueCount; i += step) {
const size = v8.serialize(values[i]).length
maxSize = Math.max(size, maxSize)
}
// Sends a warning once if any of the chunkSizes exceeds approx 500kb limit
if (showMaxSizeWarning && maxSize > 500000) {
report.warn(
`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.`
)
}
// Max size of a Buffer is 2gb (yeah, we're assuming 64bit system)
// https://stackoverflow.com/questions/8974375/whats-the-maximum-size-of-a-node-js-buffer
// Use 1.5gb as the target ceiling, allowing for some margin of error
return Math.floor((1.5 * 1024 * 1024 * 1024) / maxSize)
}
function prepareCacheFolder(
targetDir: string,
contents: DeepPartial<ICachedReduxState>
): void {
// Temporarily save the nodes and pages and remove them from the main redux store
// This prevents an OOM when the page nodes collectively contain too much data
const nodesMap = contents.nodes
contents.nodes = undefinedView on GitHub (pinned to e85d62f177)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/gatsby/src/redux/persist.ts:122 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of gatsbyjs/gatsby@e85d62f177 (2026-08-26).
Data as JSON: /api/errors/222d3ad806acbf21.
Report an issue: GitHub.