chatboxai/chatbox · error · Error

Backup entry is too large: ${entry.path}

Error message

Backup entry is too large: ${entry.path}

What it means

Thrown by enforceArchiveLimits() in the Uint8Array branch when a single in-memory entry's data.length exceeds the per-entry byte limit returned by backupEntryByteLimit(path) — 128 MiB for JSON paths, 512 MiB for resource paths. This is the per-entry size guard for entries already fully materialized in memory, complementing the streaming branch checks (118/119).

Source

Thrown at src/renderer/packages/backup/export-backup.ts:115

  const bytes = new TextEncoder().encode(JSON.stringify(value))
  if (bytes.length > MAX_BACKUP_JSON_ENTRY_BYTES) throw new Error(`Backup JSON entry is too large: ${path}`)
  return {
    archive: { path, data: bytes, compress: true },
    descriptor: { path, size: bytes.length, checksum: await sha256Checksum(bytes) },
  }
}

async function* enforceArchiveLimits(
  entries: AsyncIterable<ZipArchiveEntry>
): AsyncGenerator<ZipArchiveEntry, void, unknown> {
  let entryCount = 0
  let totalUncompressedBytes = 0
  for await (const entry of entries) {
    entryCount++
    if (entryCount > DEFAULT_ZIP_LIMITS.maxEntries) throw new Error('Backup contains too many entries')
    const maxEntryBytes = backupEntryByteLimit(entry.path)
    if (entry.data instanceof Uint8Array) {
      if (entry.data.length > maxEntryBytes) throw new Error(`Backup entry is too large: ${entry.path}`)
      totalUncompressedBytes += entry.data.length
      if (totalUncompressedBytes > DEFAULT_ZIP_LIMITS.maxTotalUncompressedBytes) {
        throw new Error('Backup uncompressed size exceeds the safety limit')
      }
      yield entry
      continue
    }
    let entryBytes = 0
    const data = entry.data
    yield {
      ...entry,
      data: (async function* () {
        for await (const chunk of data) {
          entryBytes += chunk.length
          totalUncompressedBytes += chunk.length
          if (entryBytes > maxEntryBytes) throw new Error(`Backup entry is too large: ${entry.path}`)
          if (totalUncompressedBytes > DEFAULT_ZIP_LIMITS.maxTotalUncompressedBytes) {
            throw new Error('Backup uncompressed size exceeds the safety limit')

View on GitHub (pinned to 81571269ad)

Solutions

  1. Identify the oversized resource (entry.path) and remove or shrink it before exporting.
  2. Stream the large resource instead of buffering it as a Uint8Array so it hits the streaming branch (118) which enforces the same limit incrementally.
  3. Raise MAX_BACKUP_RESOURCE_ENTRY_BYTES only if the resources are legitimately large and memory allows.

Example fix

// before
if (entry.data.length > maxEntryBytes) throw new Error(`Backup entry is too large: ${entry.path}`)

// after — include sizes for diagnosis
if (entry.data.length > maxEntryBytes) {
  throw new Error(`Backup entry is too large: ${entry.path} (${entry.data.length} > ${maxEntryBytes} bytes)`)
}
Defensive patterns

Strategy: validation

Validate before calling

function entryWithinLimit(path: string, data: Uint8Array): boolean {
  const limit = backupEntryByteLimit(path)
  return data.length <= limit
}
if (!entryWithinLimit(entry.path, entry.data)) {
  throw new Error(`Entry ${entry.path} exceeds its size limit`)
}

Try / catch

try {
  await exportBackup({ items: ['conversations'] })
} catch (error) {
  if (error instanceof Error && /Backup entry is too large/i.test(error.message)) {
    showToast(`A resource is too large: ${extractPath(error.message)}. Remove it and retry.`)
  } else throw error
}

Prevention

When it happens

Trigger: An entry whose data is a Uint8Array (already buffered) exceeds its path-specific limit. JSON entries (jsonEntry) are always Uint8Array and checked at 114 first, so this branch typically catches resource entries loaded into memory (e.g. a 600 MiB image). The path determines the limit via isBackupJsonPath.

Common situations: A session references a very large image or attachment that is loaded into memory as a single Uint8Array; a resource path is misclassified so it gets the wrong limit; corrupted resource metadata inflates a single blob.

Related errors


AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12). Data as JSON: /api/errors/99568a3d53c43e0c. Report an issue: GitHub.