mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5599] Deleting a message is not serialized against an in-flight edit of the same message — the edit is silently dropped with a 404 #3099
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#3099
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 @kolacheee on GitHub (Aug 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5599
Originally assigned to: @kolacheee on GitHub.
What happens
Editing a message and deleting that same message are not serialized against each other. If a delete lands while an edit request is still in flight, the edit is silently dropped and the edit request answers
404 Message not found— even though the message clearly existed when the user pressed save.Every other per-message mutation IS serialized:
updateMessageContent,updateMessageExtra,appendMessageAttachment,addSwipe,setActiveSwipe,removeSwipe, and friends all run through the per-message patch queue (withPatchQueue(messageExtraPatchQueues, id, ...)inpackages/server/src/services/storage/chats.storage.ts). The two deletion entry points are the exception:removeMessage(id)—chats.storage.ts:2010removeMessages(ids, chatId?)—chats.storage.ts:2020Neither takes the queue, so they interleave freely with an in-flight edit of the same message.
The interleaving
updateMessageContent(chats.storage.ts:1761) reads the row, then awaits several times before its writes. IfremoveMessageruns to completion inside one of those gaps: the edit'sdb.update(messages)matches zero rows, its re-read returns null, the swipe-mirror sync is skipped, and the function returns null → the route (chats.routes.ts:2028-2030) responds 404.When it matters
Any time an edit and a delete can race on the same message: two devices or tabs on the same chat, a batch cleanup (
removeMessages) running while someone is editing, or an agent/automation deleting messages. The outcome is benign for data integrity (the message is gone either way, no corruption), but the edit is dropped without a meaningful signal — the user gets a 404 for a message they were just looking at.Suggested direction
Wrap
removeMessageandremoveMessagesbodies in the same per-message patch queue (forremoveMessages, queue per id or acquire all ids' queues). That makes delete-vs-edit ordered like every other pair of message mutations: whichever wins the queue runs first, and the loser sees a consistent world.How verified
Code reading on current
staging(line numbers above) as part of the #5592 Phase 2 concurrency review — the patch-queue omission is visible directly: comparechats.storage.ts:1762(edit takes the queue) with:2010/:2020(deletes don't). Not a #5592 regression; this predates the sharded store.@kolacheee commented on GitHub (Aug 29, 2026):
Taking this and #5600 together (kolacheee, agent-assisted) — same file, same concurrency family. PR incoming.