Skip to content

Cleanup databases after logout#972

Draft
corbanbrook wants to merge 1 commit intomasterfrom
logout-cleanup
Draft

Cleanup databases after logout#972
corbanbrook wants to merge 1 commit intomasterfrom
logout-cleanup

Conversation

@corbanbrook
Copy link
Copy Markdown
Contributor

@corbanbrook corbanbrook commented Mar 2, 2026

New _cleanupWalletData(wallet) method (lines 1258–1280):

  • Fetches all records from signatures, transactions, messages, and recovery databases in parallel
  • Deletes any records belonging to the logged-out wallet address (using Address.isEqual for case-insensitive comparison)
  • Best-effort cleanup of auth keys: fetches the wallet's loginTopology, extracts its signers, and deletes their corresponding AuthKey entries
  • Auth key cleanup is wrapped in try/catch so an offline state won't block the logout

Soft logout (skipRemoveDevice: true branch, line 1201): calls _cleanupWalletData after the manager entry and device are removed.

Hard logout (completeLogout, line 1255): calls _cleanupWalletData after the configuration update is committed and the manager entry/device are removed.

@corbanbrook
Copy link
Copy Markdown
Contributor Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7222f7121b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1259 to +1264
const [sigs, txns, msgs, recovery] = await Promise.all([
this.shared.databases.signatures.list(),
this.shared.databases.transactions.list(),
this.shared.databases.messages.list(),
this.shared.databases.recovery.list(),
])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make wallet DB cleanup best-effort during logout

_cleanupWalletData runs list()/del() calls in fail-fast Promise.all blocks without handling errors, so any IndexedDB failure (e.g., transient open/transaction errors) will reject logout/completeLogout after the manager entry and device have already been removed. In that state the caller sees logout as failed, but retries can no longer proceed because the wallet record is gone, leaving a partial and hard-to-recover flow. This cleanup should be non-blocking (or individually guarded) like the auth-key cleanup path.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant