{"record":{"id":"01ca297568b7b301","repo":"overleaf/overleaf","slug":"error-getting-document-for-downloading","errorCode":null,"errorMessage":"error getting document for downloading","messagePattern":"error getting document for downloading","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"services/web/app/src/Features/DocumentUpdater/DocumentUpdaterController.mjs","lineNumber":36,"sourceCode":"    const { lines } = await DocumentUpdaterHandler.promises.getDocument(\n      projectId,\n      docId,\n      -1 // latest version only\n    )\n\n    res.setContentDisposition('attachment', { filename: doc.name })\n    plainTextResponse(res, lines.join('\\n'))\n  } catch (err) {\n    if (err.name === 'NotFoundError') {\n      logger.warn(\n        { err, projectId, docId },\n        'entity not found when downloading doc'\n      )\n\n      return res.sendStatus(404)\n    }\n\n    logger.err(\n      { err, projectId, docId },\n      'error getting document for downloading'\n    )\n\n    return res.sendStatus(500)\n  }\n}\n\nexport default {\n  getDoc: expressify(getDoc),\n}\n","sourceCodeStart":18,"sourceCodeEnd":48,"githubUrl":"https://github.com/overleaf/overleaf/blob/28ad3b03b71cb4311decdcb55c36b33ec10d72db/services/web/app/src/Features/DocumentUpdater/DocumentUpdaterController.mjs#L18-L48","documentation":"Overleaf's DocumentUpdaterController.getDoc logs this message via logger.err when calling the document-updater service to fetch a document for download fails with an unexpected (non-'not found') error. It is a catch-all handler, not a thrown error itself; the HTTP response is a bare 500. The underlying cause is whatever error propagated from DocumentUpdaterHandler.getDoc.","triggerScenarios":"GET /project/:projectId/doc/:docId/download where the document-updater service is unreachable, times out, or returns a non-404 error while fetching the document lines.","commonSituations":"document-updater container crashed or OOMed; misconfigured DOCUMENT_UPDATER_URL; Redis (doclines cache) outage; network split between web and document-updater pods.","solutions":["Check document-updater service health and logs for the correlated error","Verify DOCUMENT_UPDATER_URL / LISTEN_ADDRESS config in both web and document-updater","Check shared Redis connectivity used for document lines","Retry the download; investigate the propagated err in the logger.err metadata"],"exampleFix":"// before\nreturn res.sendStatus(500)\n// after\nlogger.err({ err, projectId, docId }, 'error getting document for downloading')\nreturn res.status(500).json({ error: 'document download failed' })","handlingStrategy":"try-catch","validationCode":"// preflight: check document-updater reachability\nconst res = await fetch(`${process.env.DOCUMENT_UPDATER_URL}/health_check`)\nif (!res.ok) throw new Error('document-updater unavailable')","typeGuard":"function isRequestFailedError(err) {\n  return err instanceof Error && err.constructor.name === 'RequestFailedError'\n}","tryCatchPattern":"try {\n  const doc = await documentUpdaterHandler.promises.getDoc(projectId, docId)\n} catch (err) {\n  if (err?.info?.notFound) return res.sendStatus(404)\n  logger.err({ err, projectId, docId }, 'error getting document for downloading')\n  return res.sendStatus(500)\n}","preventionTips":["Monitor document-updater health endpoint from load balancers","Set explicit timeouts on inter-service HTTP calls","Alert on Redis latency shared with document-updater","Correlate the propagated err stack from logger metadata"],"tags":["http-500","document-updater","overleaf"],"backgroundTag":"downstream-service-unavailable","analyzedSha":"28ad3b03b71cb4311decdcb55c36b33ec10d72db","analyzedAt":"2026-09-03T02:10:22.807Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}