{"record":{"id":"1535761379d77c69","repo":"Mintplex-Labs/anything-llm","slug":"document-processing-is-unavailable-the-collector","errorCode":null,"errorMessage":"Document processing is unavailable. The collector service is offline.","messagePattern":"Document processing is unavailable\\. The collector service is offline\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/telegramBot/utils/media.js","lineNumber":88,"sourceCode":" * @param {Buffer} documentBuffer\n * @param {string} originalFilename - The original filename with extension\n * @returns {Promise<{text: string, filename: string}>}\n */\nasync function documentToText(documentBuffer, originalFilename) {\n  const fs = require(\"fs\");\n  const path = require(\"path\");\n  const { CollectorApi } = require(\"../../collectorApi\");\n  const { hotdirPath } = require(\"../../files\");\n\n  if (!fs.existsSync(hotdirPath)) fs.mkdirSync(hotdirPath, { recursive: true });\n\n  const sanitizedName = originalFilename.replace(/[^a-zA-Z0-9._-]/g, \"_\");\n  const filename = `telegram-doc-${Date.now()}-${sanitizedName}`;\n  fs.writeFileSync(path.join(hotdirPath, filename), documentBuffer);\n\n  const collector = new CollectorApi();\n  if (!(await collector.online())) {\n    throw new Error(\n      \"Document processing is unavailable. The collector service is offline.\"\n    );\n  }\n\n  const result = await collector.parseDocument(filename);\n  if (!result?.success || !result.documents?.length) {\n    throw new Error(\n      result?.reason || `Failed to parse document: ${originalFilename}`\n    );\n  }\n\n  const text = result.documents.map((doc) => doc.pageContent).join(\"\\n\\n\");\n  return { text, filename: originalFilename };\n}\n\n/**\n * Download the largest photo from a Telegram photo array and return\n * it as an attachment object compatible with the LLM chat pipeline.","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/telegramBot/utils/media.js#L70-L106","documentation":"Thrown by parseDocumentFromBuffer() when collector.online() resolves false before attempting a parse. The collector is a separate process/container that runs document parsing (PDF/DOCX/etc.); if it is not reachable, parsing cannot proceed and the error is raised early rather than producing a confusing parse failure. The document buffer has already been written to the hotdir.","triggerScenarios":"The collector container/process is down, restarting, or unreachable on its socket/port. A document upload via Telegram while the collector is unhealthy. First boot before the collector finished starting.","commonSituations":"Collector container crashed or OOM-killed; docker-compose missing or mis-linked the collector service; port/socket mismatch between server and collector after a config change; collector still booting during a request burst.","solutions":["Check that the collector service is running: `docker compose ps` / `docker logs collector`.","Verify the collector connection config (host/port or socket path) matches between server and collector.","Wait for collector healthcheck to pass before routing document requests.","Add a readiness probe so the server declines document uploads until the collector is online."],"exampleFix":"// before\nconst result = await collector.parseDocument(filename);\n\n// after\nif (!(await collector.online()))\n  throw new Error('Document processing is unavailable. The collector service is offline.');\nconst result = await collector.parseDocument(filename);","handlingStrategy":"validation","validationCode":"if (!(await collector.online()))\n  throw new Error('Document processing is unavailable. The collector service is offline.');","typeGuard":null,"tryCatchPattern":"try {\n  const { text } = await parseDocumentFromBuffer(buffer, name);\n} catch (e) {\n  if (e.message.includes('collector service is offline'))\n    return ctx.reply('Document processing is temporarily unavailable.');\n  throw e;\n}","preventionTips":["Add a collector healthcheck/readiness probe.","Verify collector container/service is linked and running before accepting uploads.","Decline document features in the UI when the collector is unreachable."],"tags":["telegram","collector","infrastructure","document-parsing"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}