{"record":{"id":"ceaea5c286e3d558","repo":"gatsbyjs/gatsby","slug":"couldn-t-find-temp-query-result-for-pagepath","errorCode":null,"errorMessage":"Couldn't find temp query result for \"${pagePath}\".","messagePattern":"Couldn't find temp query result for \"(.+?)\"\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/utils/page-data.ts","lineNumber":97,"sourceCode":"  return savePageQueryResultsPromise\n}\n\nexport async function savePageQueryResult(\n  pagePath: string,\n  stringifiedResult: string\n): Promise<void> {\n  savePageQueryResultsPromise = getLMDBPageQueryResultsCache().set(\n    pagePath,\n    stringifiedResult\n  ) as Promise<void>\n}\n\nexport async function readPageQueryResult(pagePath: string): Promise<string> {\n  const stringifiedResult = await getLMDBPageQueryResultsCache().get(pagePath)\n  if (typeof stringifiedResult === `string`) {\n    return stringifiedResult\n  }\n  throw new Error(`Couldn't find temp query result for \"${pagePath}\".`)\n}\n\nexport async function writePageData(\n  publicDir: string,\n  pageData: IPageDataInput,\n  slicesUsedByTemplates: Map<string, ICollectedSlices>,\n  slices: IGatsbyState[\"slices\"]\n): Promise<string> {\n  const result = await readPageQueryResult(pageData.path)\n\n  const outputFilePath = generatePageDataPath(publicDir, pageData.path)\n\n  const body = constructPageDataString(\n    pageData,\n    result,\n    slicesUsedByTemplates,\n    slices\n  )","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/utils/page-data.ts#L79-L115","documentation":"readPageQueryResult reads the page's query result from the LMDB page-query-results cache; if the stored value is not a string (key missing/evicted/corrupted) it throws. It indicates the temp query result for that page path was never persisted.","triggerScenarios":"writePageData/readPageQueryResult is called before writePageQueryResult has stored the result; LMDB cache miss or eviction; cache corruption.","commonSituations":"Race during build where read precedes write; corrupted .cache-dir; querying a page whose query never ran; LMDB lock or disk issue.","solutions":["Ensure writePageQueryResult succeeds for the page path before readPageQueryResult is called.","Clear the .cache-dir (LMDB) and public and rerun the build.","Confirm the page query actually ran (check query-runner logs) before invoking read."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"async function pageResultWritten(pagePath) {\n  const cache = getLMDBPageQueryResultsCache()\n  return typeof (await cache.get(pagePath)) === 'string'\n}","typeGuard":"async function resultIsCached(cache, pagePath) { return typeof (await cache.get(pagePath)) === 'string' }","tryCatchPattern":"try {\n  return await readPageQueryResult(pagePath)\n} catch (err) {\n  if (/Couldn't find temp query result/.test(err.message)) {\n    // re-run the page query, then retry once\n    await writePageQueryResult(pagePath, result)\n    return readPageQueryResult(pagePath)\n  }\n  throw err\n}","preventionTips":["Always await writePageQueryResult before readPageQueryResult for a given page.","Clear .cache-dir and public if LMDB state looks inconsistent.","Watch for query-runner failures that would skip the write step."],"tags":["page-data","cache","lmdb"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}