[GH-ISSUE #4441] Backup and profile export fail for users with large data directories (>1 GB assets) #2410

Closed
opened 2026-10-21 05:47:59 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @kolacheee on GitHub (Aug 2, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4441

Originally assigned to: @SpicyMarinara on GitHub.

Users with large data directories (one reported ~25 GB) cannot back up or export their data through any of the available paths. Both the "Download Backup" button and the "Export Profile" option fail with size-related errors.

What happens

Export Profile (Settings → Backup & Export → Export Profile):

  1. The default JSON exporter tries to base64-encode every asset file into a single in-memory JSON string. It hits the 256 MiB budget (PROFILE_IMPORT_BODY_LIMIT_BYTES at backup.routes.ts:82) almost immediately and returns HTTP 413 with PROFILE_EXPORT_JSON_TOO_LARGE.
  2. The client auto-retries as a ZIP — good. But the ZIP path accumulates total uncompressed asset bytes and throws ProfileArchiveTooLargeError when they exceed 1 GiB (PROFILE_ARCHIVE_TOTAL_UNCOMPRESSED_LIMIT_BYTES at backup.routes.ts:86, enforced at line 1117). The user sees "Profile ZIP export is too large" with no further fallback.

Download Backup (Settings → Backup & Export → Download Backup):

The server builds a single ZIP archive containing the profile tables (no inline assets) plus every file from all 17 BACKUP_DIRS directories. The custom ZIP writer uses 32-bit offsets only (assertZip32Value at backup.routes.ts:1394), so the total archive cannot exceed ~4 GiB. A 25 GB data directory blows past this immediately. Additionally, even if the server produced the archive, the client loads the entire response into a single Blob via await res.blob() (SettingsPanel.tsx:6874), which would OOM the browser tab for multi-GB archives.

Create Backup (on-disk folder backup):

Calls writeNativeProfileZip() (backup.routes.ts:2397) with includeAssets: true, which hits the same 1 GiB asset limit as the profile ZIP export path above. The directory copies at lines 2403-2408 never run because the profile ZIP creation throws first.

Automatic Backup:

Calls writeFullBackupArchive(), which hits the same ZIP32 ~4 GiB limit as the download path.

Net result: every backup and export path is blocked for users with >1 GiB of asset data. The only escape hatch is manually exporting individual character cards.

Try it yourself

Have a data directory with >1 GiB of assets across avatars, sprites, backgrounds, gallery, game-assets, etc. (a gallery with a few hundred images gets there quickly). Then:

  1. Go to Settings → Backup & Export → Export Profile → the JSON exporter fails, auto-retries as ZIP, ZIP also fails with "too large."
  2. Click "Download Backup" → fails with a ZIP32 size-limit error.
  3. Click "Create Backup" → fails because the embedded profile ZIP hits the 1 GiB asset cap.

Where the limits live

Constant Value File:Line Blocks
PROFILE_IMPORT_BODY_LIMIT_BYTES 256 MiB backup.routes.ts:82 JSON profile export
PROFILE_ARCHIVE_TOTAL_UNCOMPRESSED_LIMIT_BYTES 1 GiB backup.routes.ts:86 Profile ZIP export, on-disk backup
ZIP32_MAX_VALUE ~4 GiB backup.routes.ts:91 Backup download, automatic backup
Client res.blob() browser RAM SettingsPanel.tsx:6874 Backup download (even if server limits were raised)

Possible directions

  • On-disk backup (POST /backup): skip the embedded profile ZIP for assets and just copy the raw directories (which it already does at lines 2403-2408). The profile ZIP should only contain the database tables/manifest. This removes the 1 GiB bottleneck for on-disk backups with zero format changes.
  • Backup download (POST /backup/download): switch from ZIP32 to ZIP64 (or stream a tar), and change the client from res.blob() to a streamed download (the showSaveFilePicker path at SettingsPanel.tsx:6885 already has a writable stream — pipe to it chunk-by-chunk instead of buffering the full blob).
  • Profile export: consider whether the ZIP format needs to embed all assets at all, or whether a "tables + metadata only" export with a separate "asset bundle" option would be more practical for large profiles.
Originally created by @kolacheee on GitHub (Aug 2, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4441 Originally assigned to: @SpicyMarinara on GitHub. Users with large data directories (one reported ~25 GB) cannot back up or export their data through any of the available paths. Both the "Download Backup" button and the "Export Profile" option fail with size-related errors. ## What happens **Export Profile** (Settings → Backup & Export → Export Profile): 1. The default JSON exporter tries to base64-encode every asset file into a single in-memory JSON string. It hits the 256 MiB budget (`PROFILE_IMPORT_BODY_LIMIT_BYTES` at `backup.routes.ts:82`) almost immediately and returns HTTP 413 with `PROFILE_EXPORT_JSON_TOO_LARGE`. 2. The client auto-retries as a ZIP — good. But the ZIP path accumulates total uncompressed asset bytes and throws `ProfileArchiveTooLargeError` when they exceed 1 GiB (`PROFILE_ARCHIVE_TOTAL_UNCOMPRESSED_LIMIT_BYTES` at `backup.routes.ts:86`, enforced at line 1117). The user sees "Profile ZIP export is too large" with no further fallback. **Download Backup** (Settings → Backup & Export → Download Backup): The server builds a single ZIP archive containing the profile tables (no inline assets) plus every file from all 17 `BACKUP_DIRS` directories. The custom ZIP writer uses 32-bit offsets only (`assertZip32Value` at `backup.routes.ts:1394`), so the total archive cannot exceed ~4 GiB. A 25 GB data directory blows past this immediately. Additionally, even if the server produced the archive, the client loads the entire response into a single `Blob` via `await res.blob()` (`SettingsPanel.tsx:6874`), which would OOM the browser tab for multi-GB archives. **Create Backup** (on-disk folder backup): Calls `writeNativeProfileZip()` (`backup.routes.ts:2397`) with `includeAssets: true`, which hits the same 1 GiB asset limit as the profile ZIP export path above. The directory copies at lines 2403-2408 never run because the profile ZIP creation throws first. **Automatic Backup:** Calls `writeFullBackupArchive()`, which hits the same ZIP32 ~4 GiB limit as the download path. Net result: **every backup and export path is blocked** for users with >1 GiB of asset data. The only escape hatch is manually exporting individual character cards. ## Try it yourself Have a data directory with >1 GiB of assets across avatars, sprites, backgrounds, gallery, game-assets, etc. (a gallery with a few hundred images gets there quickly). Then: 1. Go to Settings → Backup & Export → Export Profile → the JSON exporter fails, auto-retries as ZIP, ZIP also fails with "too large." 2. Click "Download Backup" → fails with a ZIP32 size-limit error. 3. Click "Create Backup" → fails because the embedded profile ZIP hits the 1 GiB asset cap. ## Where the limits live | Constant | Value | File:Line | Blocks | |---|---|---|---| | `PROFILE_IMPORT_BODY_LIMIT_BYTES` | 256 MiB | `backup.routes.ts:82` | JSON profile export | | `PROFILE_ARCHIVE_TOTAL_UNCOMPRESSED_LIMIT_BYTES` | 1 GiB | `backup.routes.ts:86` | Profile ZIP export, on-disk backup | | `ZIP32_MAX_VALUE` | ~4 GiB | `backup.routes.ts:91` | Backup download, automatic backup | | Client `res.blob()` | browser RAM | `SettingsPanel.tsx:6874` | Backup download (even if server limits were raised) | ## Possible directions - **On-disk backup (`POST /backup`)**: skip the embedded profile ZIP for assets and just copy the raw directories (which it already does at lines 2403-2408). The profile ZIP should only contain the database tables/manifest. This removes the 1 GiB bottleneck for on-disk backups with zero format changes. - **Backup download (`POST /backup/download`)**: switch from ZIP32 to ZIP64 (or stream a tar), and change the client from `res.blob()` to a streamed download (the `showSaveFilePicker` path at `SettingsPanel.tsx:6885` already has a writable stream — pipe to it chunk-by-chunk instead of buffering the full blob). - **Profile export**: consider whether the ZIP format needs to embed all assets at all, or whether a "tables + metadata only" export with a separate "asset bundle" option would be more practical for large profiles.
bsakaguchi 2026-10-21 05:47:59 +07:00
  • closed this issue
  • added the
    bug
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#2410
No description provided.