{"record":{"id":"14b4893eb8d71202","repo":"gatsbyjs/gatsby","slug":"we-couldn-t-load-path-prefix-page-data-sq","errorCode":null,"errorMessage":"We couldn't load \"${__PATH_PREFIX__}/page-data/sq/d/${staticQueryHash}.json\"","messagePattern":"We couldn't load \"(.+?)/page-data/sq/d/(.+?)\\.json\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/cache-dir/loader.js","lineNumber":553,"sourceCode":"\n        // get list of static queries to get\n        const staticQueryBatchPromise = Promise.all(\n          dedupedStaticQueryHashes.map(staticQueryHash => {\n            // Check for cache in case this static query result has already been loaded\n            if (this.staticQueryDb[staticQueryHash]) {\n              const jsonPayload = this.staticQueryDb[staticQueryHash]\n              return { staticQueryHash, jsonPayload }\n            }\n\n            return this.memoizedGet(\n              `${__PATH_PREFIX__}/page-data/sq/d/${staticQueryHash}.json`\n            )\n              .then(req => {\n                const jsonPayload = JSON.parse(req.responseText)\n                return { staticQueryHash, jsonPayload }\n              })\n              .catch(() => {\n                throw new Error(\n                  `We couldn't load \"${__PATH_PREFIX__}/page-data/sq/d/${staticQueryHash}.json\"`\n                )\n              })\n          })\n        ).then(staticQueryResults => {\n          const staticQueryResultsMap = {}\n\n          staticQueryResults.forEach(({ staticQueryHash, jsonPayload }) => {\n            staticQueryResultsMap[staticQueryHash] = jsonPayload\n            this.staticQueryDb[staticQueryHash] = jsonPayload\n          })\n\n          return staticQueryResultsMap\n        })\n\n        return (\n          Promise.all([componentChunkPromises, staticQueryBatchPromise])\n            .then(([pageResources, staticQueryResults]) => {","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/cache-dir/loader.js#L535-L571","documentation":"Thrown by ProdLoader when fetching a static query result JSON file from the server fails. During production page load, Gatsby fetches /page-data/sq/d/<hash>.json for each static query (useStaticQuery / StaticQuery). If the HTTP request fails or returns an error, the .catch handler throws this error with the full URL.","triggerScenarios":"The browser sends a GET request for the static query JSON and it fails — network error, 404 (file not deployed), 500 (server error), or CORS issue. The .catch in the loader swallows the original error and throws this generic message.","commonSituations":"Incomplete deployment (static query JSON files not uploaded to the CDN/host), CDN cache miss returning 404, intermittent network failures on mobile/slow connections, deploying a new build while users have an older bundle cached (hash mismatch), or a hosting config that doesn't serve .json files from public/page-data/.","solutions":["Verify the static query JSON exists at the reported URL by opening it directly in a browser or using curl.","Ensure your deployment includes the entire public/page-data/ directory, including the sq/d/ subdirectory.","If using a CDN, purge the cache after deploying a new build so old hashes don't 404.","Check hosting configuration (e.g. nginx, Netlify, Vercel) serves JSON files with correct content-type and no redirect rules that break the path."],"exampleFix":"# before — deployment missing page-data\n# only public/ root uploaded, page-data/sq/d/ omitted\n\n# after — ensure full recursive upload\nrsync -av --delete public/ user@host:/var/www/site/\n# or in CI: ensure `gatsby build` output (public/) is uploaded in full","handlingStrategy":"retry","validationCode":"// Pre-deploy check: verify static query JSONs exist in public/\nconst fs = require('fs')\nconst path = require('path')\n\nfunction checkStaticQueryOutputs(publicDir) {\n  const sqDir = path.join(publicDir, 'page-data', 'sq', 'd')\n  if (!fs.existsSync(sqDir)) {\n    console.warn('No static query output directory found')\n    return\n  }\n  const files = fs.readdirSync(sqDir)\n  console.log(`Found ${files.length} static query JSON files`)\n}\ncheckStaticQueryOutputs('public')","typeGuard":null,"tryCatchPattern":"// Add a retry wrapper around static query fetches in custom code\n// (Gatsby's loader handles this internally, but for custom fetches:)\nasync function fetchWithRetry(url, retries = 3) {\n  for (let i = 0; i < retries; i++) {\n    try {\n      const res = await fetch(url)\n      if (res.ok) return res.json()\n    } catch {}\n    await new Promise(r => setTimeout(r, 1000 * (i + 1)))\n  }\n  throw new Error(`Failed to load ${url}`)\n}","preventionTips":["Deploy the entire public/ directory recursively, including page-data/sq/d/.","Purge CDN cache after deploying a new build.","Set long cache headers with content-hash-based filenames to avoid stale-file mismatches.","Monitor 404s on page-data paths in your hosting analytics."],"tags":["static-query","production","network","deployment","cdn"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}