{"record":{"id":"34261bb58a2c7f7d","repo":"gatsbyjs/gatsby","slug":"json-file-store-failed-to-json-parse-this-string-34261b","errorCode":null,"errorMessage":"json-file-store failed to JSON.parse this string: `${dataString.replace(/\\n/g, `⏎`)}","messagePattern":"json-file-store failed to JSON\\.parse this string: `(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/cache/json-file-store.ts","lineNumber":141,"sourceCode":"        // JSON.parse is sync so we need to return a buffer sync, we will fill the buffer later\n        const buffer = Buffer.alloc(value.size)\n        externalBuffers.push({\n          index: +value.index,\n          buffer: buffer,\n        })\n        return buffer\n      } else if (\n        value &&\n        value.type === `Infinity` &&\n        typeof value.sign === `number`\n      ) {\n        return Infinity * value.sign\n      } else {\n        return value\n      }\n    })\n  } catch (e) {\n    throw new Error(\n      \"json-file-store failed to JSON.parse this string: `\" +\n        dataString.replace(/\\n/g, `⏎`)\n    )\n  }\n\n  // read external buffers\n  await Promise.all(\n    externalBuffers.map(async function (externalBuffer) {\n      if (options.zip) {\n        const bufferCompressed = await promisify(fs.readFile)(\n          path + `-` + +externalBuffer.index + `.bin` + zipExtension\n        )\n        const buffer = await promisify(zlib.unzip)(bufferCompressed)\n        buffer.copy(externalBuffer.buffer)\n      } else {\n        const fd = await promisify(fs.open)(\n          path + `-` + +externalBuffer.index + `.bin` + zipExtension,\n          `r`","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/e85d62f1779e353eaac1753211629a26d123e26c/packages/gatsby/src/cache/json-file-store.ts#L123-L159","documentation":"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.","triggerScenarios":"Thrown at packages/gatsby/src/cache/json-file-store.ts:141 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the .cache directory and rebuild","Avoid editing cache files manually","Ensure builds are not interrupted mid-write; use a clean CI cache"],"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"}