mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2537] [MERGED] fix(updates): flush the file-backed store before exiting after an in-app update #5640
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#5640
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/2537
Author: @Romuromylus
Created: 6/9/2026
Status: ✅ Merged
Merged: 6/9/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/updater-flush-before-exit📝 Commits (2)
8579238fix(updates): flush the file-backed store before exiting after an in-app update7bae4bbMerge branch 'staging' into fix/updater-flush-before-exit📊 Changes
1 file changed (+21 additions, -4 deletions)
View changed files
📝
packages/server/src/routes/updates.routes.ts(+21 -4)📄 Description
Linked issue
Closes #2527
Why this change
The in-app updater's
POST /api/updates/applyroute exited viasetTimeout(..., 500)→process.exit(0). The file-backed store is a debounced write-back cache: a write arms a 750ms debounce (SAVE_DEBOUNCE_MS) before it touches disk. Durable flushes only happen via the graceful path (app.close()→ FastifyonClose→closeDB()→fileStore.close()→flush(true)) or an explicitflushDB(). A bareprocess.exit(0)runs neither — Node does not execute FastifyonClosehooks or the store'sbeforeExitautosave on an explicit exit — and the 500ms timer is shorter than the 750ms debounce, so any write landing during the install/rebuild step (an in-progress message persist, swipe patch, autonomous-agent turn) is silently dropped on update.What changed
packages/server/src/routes/updates.routes.ts:asyncandawait app.close()beforeprocess.exit(0), so the sameonClose → closeDB → fileStore.close → flush(true)chain that runs on SIGTERM/SIGINT (index.tsshutdown()) now runs here, plus a clean sidecar stop.try/catchalways reachesprocess.exit(0)so the process still halts for the user's relaunch even if the flush fails; the failure is surfaced via err-first Pino logging (exit code kept at 0 so a supervisor doesn't misread a post-successful-update teardown as a crash).app.close()forcesflush(true)regardless).The HTTP response is already returned before the timer fires, so making the callback async does not delay or alter the response. Not a hot path —
applyis a rare, privileged/loopback-gated user action.Not a regression: byte-identical on
main; long-standing shared bug.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
pnpm checkpasses locally. The change reuses the exact graceful-shutdown path already exercised on every SIGTERM/SIGINT viaindex.ts shutdown()(await app.close()thenprocess.exit(0)), so the flush-on-close chain is pre-existing behavior — this PR only routes the updater's exit through it.Still to verify manually against the deploy (timing-sensitive, hard to hit by hand):
app.close()resolves, and no "Graceful shutdown failed" line.Docs and release impact
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.