signum-network / signum-xt-wallet

Cryptocurrency wallet for the green Signum 🍀 blockchain as an extension for your browser.
MIT License
14 stars 6 forks source link

Chrome MV3: Service Worker Lifetime interrupts communication between DApps and Wallet #24

Closed ohager closed 2 years ago

ohager commented 2 years ago

WORKAROUND

This is an imminent problem of the service workers nature and requires more research and eventually a rewrite of the messaging architecture

As a workaround at this time there are two possibilities:

  1. Once connecting or signing fails, reload the DApp (F5) to reestablish the communication - the service worker will be active again for about 5 minutes (I know this is a bad workaround and it sucks)
  2. [recommended] Use Firefox as long as this issue persists with Chrome

Describe the bug Due to the nature of Service Workers, it goes inactive after some time (about 5 MInutes). Inactive service workers interrupts all kind event listeners, such that no communication between a DApp and the wallet is possible anymore. Only a reload of the DApp reactivates the service worker

To Reproduce Steps to reproduce the behavior:

  1. Open a DApp
  2. Connect to the Wallet
  3. Wait about five to ten minutes
  4. Try to sign or somehow interact with the wallet
  5. You should get an error, like unkwnown error or somehting about port disconnection

See also #23

Expected behavior All interaction works without such problems

Screenshots If applicable, add screenshots to help explain your problem.

Browser (please complete the following information):

Additional context This is a known issue in the community and often reported.

ohager commented 2 years ago

I already tried some polling techniques to keep the service worker alive.... still working on some solution otherwise I would need to review and refactor the entire communication infrastructure

ohager commented 2 years ago

After some trials and further research, I am not able to keep the service worker active permanently. It seems that I need to find other ways to establish a robust communication for the Version 3 Scenario.

ohager commented 2 years ago

https://groups.google.com/a/chromium.org/g/chromium-extensions/c/jpFZj1p7mJc

ohager commented 2 years ago

https://stackoverflow.com/questions/66618136/persistent-service-worker-in-chrome-extension