overleaf/overleaf · error
error getting document for downloading
Error message
error getting document for downloading
What it means
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.
Source
Thrown at services/web/app/src/Features/DocumentUpdater/DocumentUpdaterController.mjs:36
const { lines } = await DocumentUpdaterHandler.promises.getDocument(
projectId,
docId,
-1 // latest version only
)
res.setContentDisposition('attachment', { filename: doc.name })
plainTextResponse(res, lines.join('\n'))
} catch (err) {
if (err.name === 'NotFoundError') {
logger.warn(
{ err, projectId, docId },
'entity not found when downloading doc'
)
return res.sendStatus(404)
}
logger.err(
{ err, projectId, docId },
'error getting document for downloading'
)
return res.sendStatus(500)
}
}
export default {
getDoc: expressify(getDoc),
}
View on GitHub (pinned to 28ad3b03b7)
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
Example fix
// before
return res.sendStatus(500)
// after
logger.err({ err, projectId, docId }, 'error getting document for downloading')
return res.status(500).json({ error: 'document download failed' }) Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: check document-updater reachability
const res = await fetch(`${process.env.DOCUMENT_UPDATER_URL}/health_check`)
if (!res.ok) throw new Error('document-updater unavailable') Type guard
function isRequestFailedError(err) {
return err instanceof Error && err.constructor.name === 'RequestFailedError'
} Try / catch
try {
const doc = await documentUpdaterHandler.promises.getDoc(projectId, docId)
} catch (err) {
if (err?.info?.notFound) return res.sendStatus(404)
logger.err({ err, projectId, docId }, 'error getting document for downloading')
return res.sendStatus(500)
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: document-updater container crashed or OOMed; misconfigured DOCUMENT_UPDATER_URL; Redis (doclines cache) outage; network split between web and document-updater pods.
Related errors
- Oops, something went wrong
- Server Error
- error_performing_request
- doc would become too large if appending this text
- document not found: ${docId}
AI-assisted analysis of overleaf/overleaf@28ad3b03b7 (2026-09-03).
Data as JSON: /api/errors/01ca297568b7b301.
Report an issue: GitHub.