{"record":{"id":"c1121c4cf51b42be","repo":"gatsbyjs/gatsby","slug":"the-result-of-this-staticquery-could-not-be-fetche","errorCode":null,"errorMessage":"The result of this StaticQuery could not be fetched.\n\nThis is likely a bug in Gatsby and if refreshing the page does not fix it, please open an issue in https://github.com/gatsbyjs/gatsby/issues","messagePattern":"The result of this StaticQuery could not be fetched\\.\n\nThis is likely a bug in Gatsby and if refreshing the page does not fix it, please open an issue in https://github\\.com/gatsbyjs/gatsby/issues","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/cache-dir/static-query.js","lineNumber":83,"sourceCode":"\n  const context = React.useContext(StaticQueryContext)\n\n  // query is a stringified number like `3303882` when wrapped with graphql, If a user forgets\n  // to wrap the query in a grqphql, then casting it to a Number results in `NaN` allowing us to\n  // catch the misuse of the API and give proper direction\n  if (isNaN(Number(query))) {\n    throw new Error(`useStaticQuery was called with a string but expects to be called using \\`graphql\\`. Try this:\n\nimport { useStaticQuery, graphql } from 'gatsby';\n\nuseStaticQuery(graphql\\`${query}\\`);\n`)\n  }\n\n  if (context[query]?.data) {\n    return context[query].data\n  } else {\n    throw new Error(\n      `The result of this StaticQuery could not be fetched.\\n\\n` +\n        `This is likely a bug in Gatsby and if refreshing the page does not fix it, ` +\n        `please open an issue in https://github.com/gatsbyjs/gatsby/issues`\n    )\n  }\n}\n\nexport { StaticQuery, StaticQueryContext, useStaticQuery }\n","sourceCodeStart":65,"sourceCodeEnd":92,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/cache-dir/static-query.js#L65-L92","documentation":"`useStaticQuery` looked up its query hash in `StaticQueryContext` and found no entry with `.data`. The hash should have been injected at build time by the query extractor; a miss means the runtime context and the build-time extracted data diverged. The message itself labels this a likely Gatsby bug.","triggerScenarios":"Running after a build/extract that failed to register the static query; the component's compiled hash differs from what is in `page-data`/`app-data`; SSR or dev-server stale state serving mismatched data.","commonSituations":"Leftover `.cache`/`public` after a Gatsby upgrade; switching branches with different queries without clearing cache; a failed partial build; HMR desync in develop.","solutions":["Stop the dev/build process and delete `.cache` and `public`, then re-run.","Verify all Gatsby packages share one version (`npm ls @gatsbyjs/reach-router` / `gatsby` etc.).","Trigger a hard refresh in the browser to rule out a stale client bundle.","If it persists, capture the query and open an issue at the URL in the message."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// In app code you generally cannot catch this usefully (it throws during render).\n// Treat it as a build/CI signal: detect non-zero exit from `gatsby build` and\n// clear `.cache`/`public` before retrying.\ntry {\n  await runBuild()\n} catch (e) {\n  if (/StaticQuery could not be fetched/.test(String(e))) {\n  await fs.rm(\".cache\", { recursive: true, force: true })\n  await fs.rm(\"public\", { recursive: true, force: true })\n  throw e\n  }\n  throw e\n}\n","preventionTips":["Add a clean-cache step to CI on every build.","Pin all Gatsby packages to one version to avoid context/data format drift.","Avoid killing builds with SIGKILL; let them shut down so cache writes finish."],"tags":["gatsby","build","cache","internal","static-query"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}