mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5587] [MERGED] fix: Termux heap default and profile-restore .native marker regressions #6837
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#6837
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/5587
Author: @Romuromylus
Created: 8/28/2026
Status: ✅ Merged
Merged: 8/29/2026
Merged by: @Romuromylus
Base:
staging← Head:fix/5585-termux-heap-default📝 Commits (10+)
43a085dfix(termux): scale the default Node heap with profile size and device RAM7ea6711test(launcher): clarify the flat-2GB guard message4b8af77Merge branch 'staging' into fix/5585-termux-heap-default94eb5e4Merge remote-tracking branch 'pasta/staging' into fix/5585-termux-heap-defaultf098e67Merge branch 'staging' into fix/5585-termux-heap-defaultf88f1f2docs: document the unknown-device-memory 1536 MiB heap fallbacked50304Merge remote-tracking branch 'pasta/staging' into fix/5585-termux-heap-defaultb1736a1docs: state the heap change as restored headroom under device caps4cbedfdfix(import): tolerate the seeder's empty .native markers in profile restoresfad9082Merge remote-tracking branch 'pasta/staging' into fix/5585-termux-heap-default📊 Changes
6 files changed (+62 additions, -13 deletions)
View changed files
📝
CHANGELOG.md(+2 -0)📝
android/README.md(+1 -1)📝
packages/server/src/services/import/profile-import-assets.ts(+13 -1)📝
scripts/regressions/launcher/format-guard.regression.mjs(+5 -2)📝
scripts/regressions/profile-import-asset-security.regression.ts(+29 -0)📝
start-termux.sh(+12 -9)📄 Description
Linked issue
Closes #5585
Closes #5619
Why this change
Since v2.4.4, Termux installs with large structured profiles crash with
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory(exit 134) during normal chat use. v2.4.4 replaced the flat 2 GiB launcher heap default with an adaptive default computed as on-disk profile size + a flat 512 MiB allowance, hard-capped at 1536 MiB (#5471, #5515). That model undershoots real heap need: the file-backed store keeps every row in memory, V8's object representation runs well above the serialized JSON byte size, and flushes serialize dirty tables on top of the live rows. A profile that ran comfortably inside the old 2 GiB default can exceed 1536 MiB and abort.The reporter's setup is literally the pinned regression fixture:
resolve_default_node_heap_mb 1153434 8388608(a ~1.1 GiB profile on an 8 GiB device) resolved 1536, and their diagnostics show a 1632 MiB heap limit (--max-old-space-size=1536plus V8's non-old spaces) with 1097 MiB already in use shortly after a restart, then a Mark-Compact at 1594 MiB reclaiming only ~82 MB before the abort — a live working set, not garbage churn.I also swept the whole v2.4.3..v2.4.4 server diff for a genuine leak before touching the launcher: no unbounded live-retention accumulator landed in that window (the only new module-level container in the entire server is the bounded
fileTableShardStrategiesmap). The regression is the heap budget, not a leak.Folded in per maintainer decision: restoring a full profile backup fails on the game-asset seeder's own
.nativedirectory markers.ensureNativeMarkers(seed-game-assets.ts) writes an empty.nativefile into every bundled asset directory, profile export archives those directories verbatim, and the 2.4.4 import asset validation rejects the marker as an unsupported image undergame-assets/sprites/, aborting the entire restore — fatal for a user restoring onto a fresh device (#5619, reported on Discord).What changed
start-termux.sh:resolve_default_node_heap_mbnow budgets roughly twice the on-disk structured profile plus 512 MiB of headroom (still 128 MiB steps, still the 1 GiB floor). The quarter-of-physical-RAM device cap remains the small-phone bound and now also enforces the 1 GiB floor on very low-RAM devices; the conservative flat 1536 MiB clamp applies only when/proc/meminfocannot be read. ExplicitNODE_OPTIONSheap limits remain authoritative, and the flat 2 GiB automatic default stays gone — a large grant now requires a device whose RAM justifies it.scripts/regressions/launcher/format-guard.regression.mjs: the reporter-shaped fixture (~1.1 GiB profile, 8 GiB device) now expects 2048; added fixtures for a mid-size profile (1536), a 3 GiB device (floored at 1024), and unknown device memory (clamped at 1536). Zero-profile and 4 GiB-device fixtures are unchanged at 1024.android/README.md: updated the heap-selection description.CHANGELOG.md: Unreleased fix entry.Resolved defaults before → after: ~1.1 GiB profile / 8 GiB device: 1536 → 2048 (what pre-2.4.4 gave it). Fresh install / 8 GiB: 1024 → 1024. ~1.1 GiB profile / 4 GiB device: 1024 → 1024. ~1.1 GiB profile / unknown RAM: 1536 → 1536.
packages/server/src/services/import/profile-import-assets.ts: import now tolerates exactly the seeder's marker — a file named.nativeundergame-assets/, only when empty — and keeps image validation for everything else; a non-empty file using the marker name is still rejected, so the smuggling posture is unchanged.scripts/regressions/profile-import-asset-security.regression.ts: two new cases — empty.nativemarkers undergame-assets/sprites/andgame-assets/backgrounds/pack/stage successfully; a non-empty.nativeis rejected.CHANGELOG.md: Unreleased fix entry for #5619.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Ran
node scripts/run-regressions.mjs --filter profile-import-asset-securitylocally — passes with the new.nativemarker cases.Ran
pnpm checklocally (passes).Ran the full
regression:launcher-updatelane script-by-script (all seven pass, including the format guard with the new heap fixtures).The Docker/EasyPanel deploy path does not execute
start-termux.sh, so the running-app checks don't exercise this change; the launcher regression lane is the executable coverage.The Playwright smoke lanes (desktop-chromium, mobile-chromium, mobile-webkit) fail on this PR the same way they fail on the current
staginghead run (different flaky client e2e cases per run); this PR touches no client or server code, so those lanes cannot exercise it.complete-node-regressions,pnpm-validate, andcontainer-build-testare green.Still needs a real-device confirmation: a Termux install with a large profile should log
Node.js heap limit set to 2048 MiB for this profile and deviceon an 8 GiB phone and survive a long chat session. I'd appreciate the reporter confirming on their device once this lands onstaging.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)UI evidence (if applicable)
Not applicable — Termux launcher and regression fixtures only.
Summary by CodeRabbit
Bug Fixes
NODE_OPTIONSoverrides.Documentation
Tests
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.