{"record":{"id":"c2027d0011e00ad4","repo":"gatsbyjs/gatsby","slug":"11904","errorCode":"11904","errorMessage":"Expected compiled files not found after compilation for ${siteRoot} after ${retries} retries.\\nFile expected to be valid: ${compiledFileLocation}${sourceFileLocation ? `\\nCompiled from: ${sourceFileLocation}` : ``}\\n\\nPlease run \"gatsby clean\" and try again. If the issue persists, please open an issue with a reproduction at https://gatsby.dev/new-issue for more help.","messagePattern":"Expected compiled files not found after compilation for (.+?) after (.+?) retries\\.\\\\nFile expected to be valid: (.+?)(.+?)` : ``\\}\\\\n\\\\nPlease run \"gatsby clean\" and try again\\. If the issue persists, please open an issue with a reproduction at https://gatsby\\.dev/new-issue for more help\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"packages/gatsby/src/utils/parcel/compile-gatsby-files.ts","lineNumber":159,"sourceCode":"    await emptyDir(distDir)\n\n    await exponentialBackoff(retry)\n\n    let bundles: RunParcelReturn = []\n    try {\n      // sometimes parcel segfaults which is not something we can recover from, so we run parcel\n      // in child process and IF it fails we try to delete parcel's cache (this seems to \"fix\" the problem\n      // causing segfaults?) and retry few times\n      // not ideal, but having gatsby segfaulting is really frustrating and common remedy is to clean\n      // entire .cache for users, which is not ideal either especially when we can just delete parcel's cache\n      // and to recover automatically\n      bundles = await worker.single.runParcel(siteRoot)\n    } catch (error) {\n      if (error.diagnostics) {\n        handleErrors(error.diagnostics)\n        return\n      } else if (retry >= RETRY_COUNT) {\n        reporter.panic({\n          id: `11904`,\n          error,\n          context: {\n            siteRoot,\n            retries: RETRY_COUNT,\n            sourceMessage: error.message,\n          },\n        })\n      } else {\n        await exponentialBackoff(retry)\n        try {\n          await remove(getCacheDir(siteRoot))\n        } catch {\n          // in windows we might get \"EBUSY\" errors if LMDB failed to close, so this try/catch is\n          // to prevent EBUSY errors from potentially hiding real import errors\n        }\n        await compileGatsbyFiles(siteRoot, retry + 1)\n        return","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/utils/parcel/compile-gatsby-files.ts#L141-L177","documentation":"Thrown when the Parcel bundling worker fails to produce Gatsby-file bundles and all `RETRY_COUNT` (5) retry attempts are exhausted. The code runs Parcel in a worker to survive segfaults; on failure it clears Parcel's cache and retries with exponential backoff. If the error carries `diagnostics` it is handled as a normal compile error, otherwise after the final retry a panic is raised with siteRoot, retry count, and the underlying error message. The user is pointed to `gatsby clean`.","triggerScenarios":"`worker.single.runParcel(siteRoot)` throws an exception without a `diagnostics` property on the 5th (final) retry. Typically a native segfault inside Parcel/worker, an out-of-memory kill, a corrupt Parcel cache that clearing did not fix, or a Parcel internal error unrelated to source diagnostics.","commonSituations":"Running out of memory during develop/build on large sites; flaky native parcel cache after an interrupted run; Node/Parcel version skew after a Gatsby upgrade; concurrent Gatsby processes fighting over `.cache/.parcel-cache`; antivirus/FS watcher interfering with the worker.","solutions":["Run `gatsby clean` to wipe `.cache` and `public`, then retry.","Free memory / close other heavy processes; if in CI, increase the node memory limit (`NODE_OPTIONS=--max-old-space-size=4096`).","Ensure only one Gatsby process is running against the project dir.","Update Gatsby and Parcel-related deps to match the Gatsby major (node engine `>= 18.0.0` for major 5).","If reproducible, capture the underlying error message and report at https://gatsby.dev/new-issue with a reproduction."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Cheap preflight before building: ensure single-process and enough memory.\nfunction preflightCompile(siteRoot) {\n  const used = process.memoryUsage().heapTotal / 1024 / 1024\n  if (used > process.env.NODE_OPTIONS_MAX_OLD_SPACE || false) {\n    return `Heap already near limit before compile; raise --max-old-space-size.`\n  }\n  return null\n}","typeGuard":null,"tryCatchPattern":"// Gatsby already retries 5x internally; wrap a higher-level clean+retry once.\nasync function buildWithClean(siteRoot, run) {\n  try { return await run() }\n  catch (e) {\n    if (/11904/.test(e?.message ?? String(e))) {\n      await require('fs-extra').remove(`${siteRoot}/.cache`)\n      return await run()\n    }\n    throw e\n  }\n}","preventionTips":["Run `gatsby clean` after upgrades before the first build.","Ensure no second Gatsby process holds `.cache/.parcel-cache`.","Set NODE_OPTIONS=--max-old-space-size=4096 on large sites.","Keep Gatsby CLI and gatsby package on the same major."],"tags":["parcel","compilation","cache","worker","retry","memory"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}