{"record":{"id":"0b369a2065dc85f4","repo":"facebook/docusaurus","slug":"generating-opensearch-file-failed","errorCode":null,"errorMessage":"Generating OpenSearch file failed.","messagePattern":"Generating OpenSearch file failed\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/docusaurus-theme-search-algolia/src/opensearch.ts","lineNumber":93,"sourceCode":"  context,\n}: {\n  context: LoadContext;\n}): Promise<void> {\n  const {\n    outDir,\n    siteConfig: {themeConfig},\n  } = context;\n  const {\n    algolia: {searchPagePath},\n  } = themeConfig as ThemeConfig;\n  if (!searchPagePath) {\n    throw new Error('no searchPagePath provided in themeConfig.algolia');\n  }\n  const fileContent = createOpenSearchFileContent({context, searchPagePath});\n  try {\n    await fs.writeFile(path.join(outDir, OPEN_SEARCH_FILENAME), fileContent);\n  } catch (err) {\n    throw new Error('Generating OpenSearch file failed.', {cause: err});\n  }\n}\n\nexport function createOpenSearchHeadTags({\n  context,\n}: {\n  context: LoadContext;\n}): HtmlTags {\n  const {\n    baseUrl,\n    siteConfig: {title},\n  } = context;\n  return {\n    tagName: 'link',\n    attributes: {\n      rel: 'search',\n      type: 'application/opensearchdescription+xml',\n      title,","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-theme-search-algolia/src/opensearch.ts#L75-L111","documentation":"Thrown by createOpenSearchFile when fs.writeFile fails while writing opensearch.xml to the build outDir. The underlying I/O error is attached via cause. This is a runtime/build failure rather than a config error; the message is generic because the real detail lives in err.cause.","triggerScenarios":"outDir is not writable, disk full, path too long, permission denied, outDir was deleted mid-build, or another process holds/locks the file.","commonSituations":"CI runners with read-only output mounts; running build as a user lacking write perms; concurrent builds writing to the same outDir; antivirus/container filesystem quirks on Windows.","solutions":["Inspect err.cause for the real filesystem error (EACCES, ENOSPC, ENOENT, EBUSY).","Ensure the build output directory exists and is writable by the build user.","Avoid running two builds into the same outDir simultaneously; clear the build dir (docusaurus clear) and retry.","Free disk space if ENOSPC."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import fs from 'fs-extra';\nawait fs.ensureDir(outDir);\nawait fs.access(path.dirname(targetFile), fs.constants.W_OK);","typeGuard":null,"tryCatchPattern":"try {\n  await createOpenSearchFile({context});\n} catch (err) {\n  const cause = (err as Error & {cause?: NodeJS.ErrnoException}).cause;\n  if (cause?.code === 'EACCES' || cause?.code === 'ENOENT') {\n    // fix permissions/ensure dir, then retry once\n  } else throw err;\n}","preventionTips":["Ensure outDir is writable before build (docusaurus clear can help).","Never run two builds into the same outDir concurrently.","Surface err.cause.code to choose the right recovery."],"tags":["algolia","opensearch","filesystem","build","cause-wrapped"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}