Clear delete-for-all guard on preflight failures#1433
Merged
Conversation
* Introduce a Map to track timeouts for recent delete-for-all actions, allowing for proper cancellation and cleanup. * Add a method to clear recent delete-for-all entries, enhancing state management during various conditions such as missing keys or insufficient balance. * Ensure that the recent delete-for-all state is consistently updated across relevant operations.
…timeout management
* Rename recentDeleteForAllGuardTimeouts to recentDeleteForAllGuards for clarity. * Enhance markRecentDeleteForAllForTarget and clearRecentDeleteForAllForTarget methods to utilize guard tokens for better state management. * Ensure proper cleanup of timeout handlers and state updates during delete-for-all actions.
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.
What Changed
This PR clears the delete-for-all action guard when deterministic preflight checks fail, so users can retry immediately after fixing local prerequisites.
recentDeleteForAllGuardsByTxidnow stores guard objects with timeout IDs so the active guard for a target message can be cleared explicitly.clearRecentDeleteForAllGuardremoves only the current guard instance, avoiding stale timeout callbacks from clearing a newer guard for the same message.deleteMessageForAllclears the guard when keys are missing, balance validation fails, or recipient keys cannot be loaded.Fixed Flow
Why
The previous guard always lived until its timeout after confirmation, even when the delete request never reached transaction creation because local prerequisites failed. That made valid follow-up attempts appear blocked by stale local state. Tracking the guard object lets the failure paths clear only the guard they created while preserving the duplicate-action protection for in-flight send attempts.
Validation
node --check app.jsgit diff --check origin/main...HEADCloses #1431