{"record":{"id":"b3277530333f6452","repo":"overleaf/overleaf","slug":"converted-document-archive-too-large","errorCode":null,"errorMessage":"converted document archive too large","messagePattern":"converted document archive too large","errorType":"validation","errorClass":"FileTooLargeError","httpStatus":null,"severity":"error","filePath":"services/web/app/src/Features/Uploads/DocumentConversionManager.mjs","lineNumber":69,"sourceCode":"  )\n\n  const outputFileName = crypto.randomUUID() + '_document-conversion' + '.zip'\n  const outputPath = Path.join(Settings.path.dumpFolder, outputFileName)\n  let outputStream\n  const abortController = new AbortController()\n\n  try {\n    const { stream, response } = await fetchStreamWithResponse(clsiUrl, {\n      method: 'POST',\n      body: formData,\n      signal: abortController.signal,\n    })\n\n    const contentLength = parseInt(response.headers.get('Content-Length'), 10)\n    if (contentLength > Settings.maxUploadSize) {\n      abortController.abort()\n      stream.destroy()\n      throw new FileTooLargeError({\n        message: 'converted document archive too large',\n        info: {\n          size: contentLength,\n        },\n      })\n    }\n\n    outputStream = fs.createWriteStream(outputPath)\n\n    await pipeline(stream, outputStream)\n    logger.debug({ outputPath }, 'received converted file from CLSI')\n  } catch (error) {\n    logger.debug({ err: error }, 'error during document conversion')\n    outputStream?.destroy()\n    // Make sure to clean up the output file if conversion didn't work\n    await fsPromises.unlink(outputPath).catch(() => {})\n\n    if (error instanceof FileTooLargeError) {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/overleaf/overleaf/blob/28ad3b03b71cb4311decdcb55c36b33ec10d72db/services/web/app/src/Features/Uploads/DocumentConversionManager.mjs#L51-L87","documentation":"DocumentConversionManager.convertDocumentToLaTeXZipArchive fetches a converted archive from the docconverter service and enforces Settings.maxUploadSize on the Content-Length header. If the converted archive exceeds the limit it aborts the request, destroys the stream, and throws FileTooLargeError with the offending size in info.","triggerScenarios":"Converting a document (e.g. .docx/.rtf) whose resulting LaTeX zip archive is larger than Settings.maxUploadSize — the converter responds with a Content-Length greater than the configured upload cap.","commonSituations":"Users converting very large Word/rich-text documents into LaTeX projects; a maxUploadSize reduced via environment/config (MAX_UPLOAD_SIZE) making previously-convertible documents fail; corrupted conversions producing bloated archives.","solutions":["Use a smaller/simpler source document or split it before conversion","Raise Settings.maxUploadSize (MAX_UPLOAD_SIZE env) on both web and converter services if the limit is too strict for your deployment","Verify the docconverter service isn't producing unexpectedly large archives (e.g. embedded media); strip media and retry"],"exampleFix":"// before (config)\nMAX_UPLOAD_SIZE=15728640  // 15MB\n// after\nMAX_UPLOAD_SIZE=52428800  // 50MB, raised so large converted archives pass","handlingStrategy":"validation","validationCode":"const head = await fetch(converterUrl, { method: 'HEAD' })\nconst size = parseInt(head.headers.get('Content-Length'), 10)\nif (size > Settings.maxUploadSize) {\n  throw new Error(`Converted archive ${size} bytes exceeds limit ${Settings.maxUploadSize}`)\n}","typeGuard":"const withinLimit = (contentLength) => Number.isFinite(contentLength) && contentLength <= Settings.maxUploadSize","tryCatchPattern":"try {\n  await DocumentConversionManager.promises.convertDocumentToLaTeXZipArchive(...)\n} catch (err) {\n  if (err instanceof Errors.FileTooLargeError) {\n    return res.status(413).json({ message: 'Converted document too large', info: err.info })\n  }\n  throw err\n}","preventionTips":["Keep MAX_UPLOAD_SIZE consistent across web and converter services","Warn users client-side when source documents are very large","Strip embedded media from documents before conversion"],"tags":["file-upload","size-limit","document-conversion"],"backgroundTag":"file-too-large","analyzedSha":"28ad3b03b71cb4311decdcb55c36b33ec10d72db","analyzedAt":"2026-09-03T02:10:22.807Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}