Repository navigation
fix(ui): send only one DELETE per message when leaving with pending deletes - #1075
Merged
jmattheis merged 1 commit intoOct 18, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1075 +/- ##
==========================================
+ Coverage 76.54% 76.69% +0.14%
==========================================
Files 68 68
Lines 3714 3724 +10
==========================================
+ Hits 2843 2856 +13
+ Misses 658 656 -2
+ Partials 213 212 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jmattheis
force-pushed
the
fix/duplicate-delete-pending-1068
branch
from
October 18, 2026 09:03
e14c68e to
2dacf74
Compare
jmattheis
approved these changes
Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Deleting messages in the WebUI and then leaving/closing the tab while the undo
snackbar is still open fires two
DELETE /message/{id}requests for the samemessage. The second one 404s:
Reported in #1068 (v3.1.1, Docker).
Root cause
ui/src/reactions.ts:8-9registers the same handler on both page-leave events:Browsers fire both, and
executePendingDeletescallsremoveSinglefor everyentry in
pendingDeletes. The guard inremoveSinglewas checked before theawaited request, while the entry was only removed after it resolved:
So the second invocation passed the guard while the first request was in flight
and sent another
DELETE. The same race exists between a page-leave event andthe snackbar's
onExitedcallback (Messages.tsx:49), which also callsremoveSinglefor the same id.Fix
removeSinglenow claims the pending delete up front, making the guard atomic —the entry (and its undo snackbar) is consumed before the request is awaited, so
any later invocation for the same id is a no-op:
The trailing
cancelPendingDelete(message)after the await is removedaccordingly (the snackbar is still closed at the same point).
Testing
Added
ui/src/tests/pendingDelete.test.tscovering both races:onExitedrace for the same id.Both assert exactly one DELETE per id.
tsc --noEmit,eslint "src/**/*.{ts,tsx}"andprettier --list-differentareall clean.
Fixes #1068