overleaf/overleaf · error · FileTooLargeError

converted document archive too large

Error message

converted document archive too large

What it means

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.

Source

Thrown at services/web/app/src/Features/Uploads/DocumentConversionManager.mjs:69

  )

  const outputFileName = crypto.randomUUID() + '_document-conversion' + '.zip'
  const outputPath = Path.join(Settings.path.dumpFolder, outputFileName)
  let outputStream
  const abortController = new AbortController()

  try {
    const { stream, response } = await fetchStreamWithResponse(clsiUrl, {
      method: 'POST',
      body: formData,
      signal: abortController.signal,
    })

    const contentLength = parseInt(response.headers.get('Content-Length'), 10)
    if (contentLength > Settings.maxUploadSize) {
      abortController.abort()
      stream.destroy()
      throw new FileTooLargeError({
        message: 'converted document archive too large',
        info: {
          size: contentLength,
        },
      })
    }

    outputStream = fs.createWriteStream(outputPath)

    await pipeline(stream, outputStream)
    logger.debug({ outputPath }, 'received converted file from CLSI')
  } catch (error) {
    logger.debug({ err: error }, 'error during document conversion')
    outputStream?.destroy()
    // Make sure to clean up the output file if conversion didn't work
    await fsPromises.unlink(outputPath).catch(() => {})

    if (error instanceof FileTooLargeError) {

View on GitHub (pinned to 28ad3b03b7)

Solutions

  1. Use a smaller/simpler source document or split it before conversion
  2. Raise Settings.maxUploadSize (MAX_UPLOAD_SIZE env) on both web and converter services if the limit is too strict for your deployment
  3. Verify the docconverter service isn't producing unexpectedly large archives (e.g. embedded media); strip media and retry

Example fix

// before (config)
MAX_UPLOAD_SIZE=15728640  // 15MB
// after
MAX_UPLOAD_SIZE=52428800  // 50MB, raised so large converted archives pass
Defensive patterns

Strategy: validation

Validate before calling

const head = await fetch(converterUrl, { method: 'HEAD' })
const size = parseInt(head.headers.get('Content-Length'), 10)
if (size > Settings.maxUploadSize) {
  throw new Error(`Converted archive ${size} bytes exceeds limit ${Settings.maxUploadSize}`)
}

Type guard

const withinLimit = (contentLength) => Number.isFinite(contentLength) && contentLength <= Settings.maxUploadSize

Try / catch

try {
  await DocumentConversionManager.promises.convertDocumentToLaTeXZipArchive(...)
} catch (err) {
  if (err instanceof Errors.FileTooLargeError) {
    return res.status(413).json({ message: 'Converted document too large', info: err.info })
  }
  throw err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of overleaf/overleaf@28ad3b03b7 (2026-09-03). Data as JSON: /api/errors/b3277530333f6452. Report an issue: GitHub.