mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #1264] [Issue]: Make the backups actually work please for us to not lose progress #616
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#616
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?
Originally created by @Navgner on GitHub (May 26, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1264
Originally assigned to: @cha1latte on GitHub.
Summary
My computer crashed, causing both
messages.jsonand its backupmessages.json.bakto become corrupted (either filled with null bytes\u0000or truncated). When this happens, Marinara Engine completely refuses to start due to unhandled JSON parsing errors during bootstrap. The only way to make the engine launch again is to manually delete or edit these files, which results in losing all conversation history and progression. This critical corruption issue has happened to me twice so far.List of corrupted files (all became unparseable or filled with
\u0000simultaneously):The crash corrupted not only the active database files but also their corresponding backups, indicating they might have been kept open or written to at the same time:
packages/server/data/storage/manifest.json&manifest.json.bakpackages/server/data/storage/tables/messages.json&messages.json.bakpackages/server/data/storage/tables/message_swipes.json&message_swipes.json.bakpackages/server/data/storage/tables/memory_chunks.json&memory_chunks.json.bakExpected behavior
The server should handle JSON parsing errors gracefully during the startup/bootstrap phase.
If both the primary database file and its backup are unparseable or corrupted:
messages.json.corrupted) to preserve them for manual recovery..bakfile from being corrupted simultaneously during a system crash.Actual behavior
The server crashes immediately during bootstrap with a
SyntaxError(e.g.,Unexpected token '\u0000'orUnterminated string in JSON) and exits. The application cannot be used at all until the user manually intervenes in the file system.Steps to reproduce
Environment
77a30faError Log 1: Corruption with Null Bytes (
\u0000){"level":50,"time":1779812749373,"pid":2020,"hostname":"SIAM","err":{"type":"SyntaxError","message":"Unexpected token '\u0000', "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"... is not valid JSON","stack":"SyntaxError: Unexpected token '\u0000', "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"... is not valid JSON\n at JSON.parse ()\n at parseJsonFile (file:///C:/Games/3Marinara/packages/server/dist/db/file-backed-store.js:265:30)..."},"msg":"[file-storage] C:\Games\3Marinara\packages\server\data\storage\tables\messages.json is corrupt; recovering from C:\Games\3Marinara\packages\server\data\storage\tables\messages.json.bak"}
Error Log 2: Corruption with Bad Control Character / Truncated JSON
{"level":50,"time":1779812749500,"pid":2020,"hostname":"SIAM","err":{"type":"SyntaxError","message":"Bad control character in string literal in JSON at position 33471828 (line 1 column 33471829)","stack":"SyntaxError: Bad control character in string literal in JSON at position 33471828 (line 1 column 33471829)\n at JSON.parse ()\n at parseJsonFile (file:///C:/Games/3Marinara/packages/server/dist/db/file-backed-store.js:273:29)..."},"msg":"[startup] Unhandled error during server bootstrap"}
Additional context
The backup mechanism (
.bak) currently fails to protect against data loss in the event of a system-wide crash, likely because both files are being modified or kept open around the same time, or because the writing process is not atomic. Implementing safe/atomic file writing (such as using a temporary file write followed by an atomic replace) would prevent database corruption on unexpected shutdowns.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@cha1latte commented on GitHub (May 26, 2026):
fixed in refactor #1312
@dougvan1701 commented on GitHub (May 29, 2026):
But how can we recover from this? My messages.json.bak is 20mg larger than the messages.json that the server creates after recovery. I am missing a TON of chats.