gatsbyjs/gatsby · error · Error
json-file-store failed to JSON.parse this string
Error message
json-file-store failed to JSON.parse this string: `${dataString.replace(/\n/g, `⏎`)} What it means
json-file-store's reviver wraps JSON.parse of a cache file; if the on-disk .cache JSON is corrupted (truncated write, manual edit, version mismatch), parse throws and is rethrown with this sentinel so the offending string (newlines visualized) is identifiable.
Solutions
- Delete the .cache directory and rebuild
- Avoid editing cache files manually
- Ensure builds are not interrupted mid-write; use a clean CI cache
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/gatsby/src/cache/json-file-store.ts:141 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/34261bb58a2c7f7d.
Report an issue: GitHub.
Appendix: source
Thrown at packages/gatsby/src/cache/json-file-store.ts:141
// JSON.parse is sync so we need to return a buffer sync, we will fill the buffer later
const buffer = Buffer.alloc(value.size)
externalBuffers.push({
index: +value.index,
buffer: buffer,
})
return buffer
} else if (
value &&
value.type === `Infinity` &&
typeof value.sign === `number`
) {
return Infinity * value.sign
} else {
return value
}
})
} catch (e) {
throw new Error(
"json-file-store failed to JSON.parse this string: `" +
dataString.replace(/\n/g, `⏎`)
)
}
// read external buffers
await Promise.all(
externalBuffers.map(async function (externalBuffer) {
if (options.zip) {
const bufferCompressed = await promisify(fs.readFile)(
path + `-` + +externalBuffer.index + `.bin` + zipExtension
)
const buffer = await promisify(zlib.unzip)(bufferCompressed)
buffer.copy(externalBuffer.buffer)
} else {
const fd = await promisify(fs.open)(
path + `-` + +externalBuffer.index + `.bin` + zipExtension,
`r`View on GitHub (pinned to e85d62f177)