mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8943] [MERGED] fix(server): stream native export images as base64 slices #8898
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8898
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8943
Author: @SpicyMarinara
Created: 11/7/2026
Status: ✅ Merged
Merged: 11/7/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/export-memory-headroom📝 Commits (1)
52c909bfix(server): stream native export images as base64 slices📊 Changes
3 files changed (+93 additions, -18 deletions)
View changed files
📝
packages/server/src/routes/characters.routes.ts(+11 -10)📝
packages/server/src/utils/export-stream.ts(+52 -4)📝
scripts/regressions/native-export-memory.regression.ts(+30 -4)📄 Description
Linked issue
Closes #8917
Why this change
scripts/regressions/native-export-memory.regression.tsflaked: the export server ran out of memory at its 128 MB heap limit. That came from the export code, not the test. The export read one image at a time, but each image still turned into several full-size strings on the JavaScript heap:readImageAsDataUrlbuilt a ~5.3 MB base64 data URL for a 4 MB file;streamJsonWithSlotcopied it withJSON.stringify, again withreplaceAllfor indented ZIP entries, and again when the stream turned it into bytes.Strings that big land in V8's large-object space, which counts against
--max-old-space-size. The old generation peaked at 114–119 MB of 128, so whether a run survived depended on when garbage collection ran. A real export of a character with a large gallery carries the same memory cost.What changed
packages/server/src/utils/export-stream.ts:DataUrlholds the image's type and bytes.jsonPiecesgenerator writes exactly the same JSON as before, but emits each image's base64 in 48 KB slices (a multiple of 3, so the slices join cleanly).packages/server/src/routes/characters.routes.ts:readImageAsDataUrl,readAvatarDataUrlandspriteExportEntriesreturnDataUrl. The PNG card's sprite reader calls.toString()and keeps its old behaviour.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Run by the agents (not a substitute for the boxes above):
pnpm check: exit 0.JSON.stringifyat space 0 and 2, with images of 0, 1, 2, 3, 49151, 49152, 49153, 98305 and 300001 bytes, nested and repeated.Still to verify by hand:
.marinara.jsonexport of a character with an avatar, sprites and a large gallery downloads and re-imports with every image.Docs and release impact
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
[PR #8943] fix(server): stream native export images as base64 slicesto [PR #8943] [MERGED] fix(server): stream native export images as base64 slices