{"record":{"id":"85960399d8ca3b50","repo":"gatsbyjs/gatsby","slug":"could-not-find-query-pagepath","errorCode":null,"errorMessage":"Could not find query ${pagePath}","messagePattern":"Could not find query (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/utils/get-page-data.ts","lineNumber":35,"sourceCode":"}\n\nasync function doGetPageData(\n  pagePath: string,\n  waitForMS: number,\n  initialWaitForMs: number\n): Promise<IPageDataWithQueryResult> {\n  const { queries, pendingPageDataWrites, pages } = store.getState()\n\n  if (!pages.has(pagePath)) {\n    throw new Error(\n      `Page \"${pagePath}\" doesn't exist. It might have been deleted recently.`\n    )\n  }\n\n  const query = queries.trackedQueries.get(pagePath)\n\n  if (!query) {\n    throw new Error(`Could not find query ${pagePath}`)\n  }\n  if (query.running !== 0) {\n    return waitNextPageData(pagePath, waitForMS, initialWaitForMs)\n  }\n  if (query.dirty !== 0) {\n    emitter.emit(`QUERY_RUN_REQUESTED`, { pagePath })\n    return waitNextPageData(pagePath, waitForMS, initialWaitForMs)\n  }\n  if (pendingPageDataWrites.pagePaths.has(pagePath)) {\n    return waitNextPageData(pagePath, waitForMS, initialWaitForMs)\n  }\n  // Results are up-to-date\n  return readPageData(pagePath)\n}\n\nasync function waitNextPageData(\n  pagePath: string,\n  remainingTime: number,","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/utils/get-page-data.ts#L17-L53","documentation":"The page exists in the redux pages map but queries.trackedQueries has no entry for its path, meaning the query runner has not registered a tracked query for it. getPageData cannot return data without a tracked query, so it throws.","triggerScenarios":"A page was created but query extraction/tracking has not run for it (component with no exported query, very-late page creation, internal state desync).","commonSituations":"Pages created after query tracking started; component files without a graphql export; custom page creation bypassing the standard pipeline; corrupted redux state.","solutions":["Ensure the page component goes through the standard query extraction pipeline (real component file with a query).","Restart the dev server / rerun the build so tracking is repopulated.","Verify the page component actually exports a pageQuery or is at least a valid component."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const { store } = require('gatsby/dist/redux')\nfunction hasTrackedQuery(pagePath) {\n  return store.getState().queries.trackedQueries.has(pagePath)\n}","typeGuard":"function pageHasTrackedQuery(state, pagePath) { return state.queries.trackedQueries.has(pagePath) }","tryCatchPattern":"try {\n  const data = await getPageData(pagePath)\n} catch (err) {\n  if (/Could not find query/.test(err.message)) {\n    // wait for query tracking to catch up, then retry once\n    await once(emitter, 'CLEAR_PENDING_PAGE_DATA_WRITE')\n    return getPageData(pagePath)\n  }\n  throw err\n}","preventionTips":["Give the dev server time to extract queries before requesting brand-new pages.","Ensure page components are real files with a (possibly empty) page query.","Avoid creating pages after the query-tracking phase has begun."],"tags":["page-data","query-runner","pages"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}