airgap-it / beacon-sdk

The beacon sdk allows developers of dApps and wallets on Tezos to implement the wallet interaction standard tzip-10.
https://walletbeacon.io
MIT License
101 stars 65 forks source link

Disconnect throws an indexedDB error #756

Closed AlexandrosGounis closed 4 months ago

AlexandrosGounis commented 5 months ago

Describe the bug (current behavior) The latest demo DApp (link) throws the following error when the Disconnect button is clicked:

IndexedDBStorage.js:73 Uncaught DOMException: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.

To Reproduce Steps to reproduce the behavior:

  1. Go to the latest example DApp deployment
  2. Click Request Permission, accept the modal (all wallet-connect and p2p wallet options would do)
  3. Click Disconnect

An indexedDB error is thrown in the console, but the pairing is successfully deleted. We came across this issue while testing other DApps on v4.2.1

IsaccoSordo commented 5 months ago

Hi @AlexandrosGounis, I’m having a hard time trying to reproduce this issue. Here are the steps I followed:

  1. Request permission, sync with the wallet, and then approve the request on the wallet side.
  2. Click "Disconnect."

Is this correct?

AlexandrosGounis commented 5 months ago

@IsaccoSordo, The issue is because the beacon client assumes an IndexedDB exists and is operable. I noticed that my web client did not have a beacon IndexedDB instance, probably because I used the Clear Site Data in the past.

To Reproduce

  1. Using Chrome on desktop, go to the latest example DApp deployment
  2. Open the dev console → Application tab → Storage → Clear Site Data
  3. Request permissions, approve
  4. Click disconnect

The issue is that indexedDB may fail to be instantiated for a number of reasons (origin policies, unsupported browser, or errors during instantiation). It might be worth catching errors on instantiation, or checking if an indexedDB exists before applying transactions on it

IsaccoSordo commented 5 months ago

Hi @AlexandrosGounis, as you correctly pointed out, there are situations in which indexDB fails to operate. With #762, we added error checking around our "IndexedDB implementation". Here's the lines of code which addresses your issue: L491-#L498

IsaccoSordo commented 4 months ago

The fix has been included in v4.2.2