Skip to content

fix(connect-multichain): recover StoreAdapterWeb after IndexedDB is force-closed - #351

Open
joaoloureirop wants to merge 2 commits into
mainfrom
fix/mcwp-821-indexeddb-stale-handle
Open

joaoloureirop wants to merge 2 commits into
mainfrom
fix/mcwp-821-indexeddb-stale-handle

Conversation

@joaoloureirop

@joaoloureirop joaoloureirop commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

StoreAdapterWeb opened IndexedDB once in the constructor and cached that IDBDatabase for the page lifetime, with no close / versionchange handling. When the browser or WKWebView force-closes the connection (Fireblocks saw this in a React Native WebView and on web), later get / set / delete fail with InvalidStateError ("The database connection is closing") or UnknownError ("Connection to Indexed Database server lost") until a full reload.

This change keeps a reconnectable handle instead of a one-shot promise:

  • On successful open, attach onclose and onversionchange and invalidate the cached connection so the next op opens a new one.
  • Retry get / set / delete once after those recoverable errors.
  • Preserve underlying request.error so connection-lost failures can trigger recovery instead of being wrapped as a generic Error.

Native RN AsyncStorage is unchanged. Custom storage overrides are unchanged.

Closing after every write (the partner workaround) is slower; this prefers reopen-on-close.

Fixes: MCWP-821

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Made with Cursor

joaoloureirop and others added 2 commits September 22, 2026 15:29
…orce-closed

Drop the cached IDBDatabase on close/versionchange and retry get/set/delete once so pairing storage keeps working without a page reload (MCWP-821).

Co-authored-by: Cursor <cursoragent@cursor.com>
…est failures

Connection-loss errors still surface so StoreAdapterWeb can retry once. Other request failures keep the existing Failed to get/set/delete messages.

Co-authored-by: Cursor <cursoragent@cursor.com>
@joaoloureirop
joaoloureirop marked this pull request as ready for review November 2, 2026 17:16
@joaoloureirop
joaoloureirop requested a review from a team as a code owner November 2, 2026 17:16
@joaoloureirop
joaoloureirop removed the request for review from a team November 18, 2026 15:36

This branch has not been deployed

No deployments
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