overleaf/overleaf · error · InvalidZipFileError

error getting bytes of zip

Error message

error getting bytes of zip

What it means

Final-tally guard in _isZipTooLarge: the zip's 'end' event fired but totalSizeInBytes was never set to a finite number, meaning no entry reported a usable size (malformed archive or entries with missing uncompressed-size metadata). Unable to prove the zip is within limits, the code rejects it as an InvalidZipFileError rather than risk an unbounded extraction.

Source

Thrown at services/web/app/src/Features/Uploads/ArchiveManager.mjs:118

          if (
            Number.isFinite(Settings.maxEntitiesPerProject) &&
            projectEntryCount > Settings.maxEntitiesPerProject
          ) {
            zipfile.close()
            return done(null, true) // too many files in zip file
          }
        }

        zipfile.readEntry()
      })

      // no more entries to read
      zipfile.on('end', () => {
        if (!Number.isFinite(totalSizeInBytes)) {
          logger.warn(
            { source, totalSizeInBytes },
            'error getting bytes of zip'
          )
          return done(new InvalidZipFileError({ info: { totalSizeInBytes } }))
        }
        done(null, false)
      })
    })
  })
}

function _extractZipFiles(source, destination) {
  return new Promise((resolve, reject) => {
    let settled = false
    const done = err => {
      if (settled) return
      settled = true
      if (err) reject(err)
      else resolve()
    }

View on GitHub (pinned to 28ad3b03b7)

Solutions

  1. Reject the upload with the invalid-zip user message
  2. Repack or repair the archive client-side before re-uploading
  3. Correlate the warned source with the producer if certain tools generate such zips
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at services/web/app/src/Features/Uploads/ArchiveManager.mjs:118 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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