tshaddix / webext-redux

A set of utilities for building Redux applications in Web Extensions.
MIT License
1.22k stars 179 forks source link

Support Manifest V3 #283

Closed 0xBigBoss closed 1 year ago

0xBigBoss commented 2 years ago

Our extension isn't live on chrome yet, but I've had success with these changes due to the fact the service worker is transient and may not be started immediately for content scripts/popup/etc.

Also, dispatching any event before subscribing to changes signals to chrome to start the service worker again.

const store = new Store()
await store.ready().then(async () =>
  await store.dispatch({ type: '' }) // wakeup service worker
)

Fixes https://github.com/tshaddix/webext-redux/issues/244

0xBigBoss commented 2 years ago

Our extension is finally live running with this pull request, and with around 80 users only one saw the service worker not starting correctly. Will keep you posted.

Chrome extension if you're interested. https://chrome.google.com/webstore/detail/pokt-wallet/adganlhbinonbpfiehjjpmklkbghkaio?hl=en

eduardoacskimlinks commented 1 year ago

@0xBigBoss, I saw you close the PR. How did it go with your approach to support Manifest V3? Did you see any issues that drove you to close the PR?

0xBigBoss commented 1 year ago

@0xBigBoss, I saw you close the PR. How did it go with your approach to support Manifest V3? Did you see any issues that drove you to close the PR?

Just doing some housekeeping, it's not good IMO to leave PRs open for a long time.

So far without any updates the reconnect approach has been working as expected. Though there are still some edge cases where a client needs to manage the service worker lifecycle correctly and does require a refresh of the page. I'm not well-versed in the service worker architecture though to suggest a solution or how to handle it programmatically.

eduardoacskimlinks commented 1 year ago

@0xBigBoss Makes sense, I am glad to hear it is working fine.

I have had a similar experience with my solution of continuously broadcasting state changes to all content scripts instead of reconnecting.

I feel that our challenges are related to the service worker's behaviour, as you pointed out. For example, I saw a few reports in the google chrome discussion group that pointed out a problem with issues in the implementation from the Google side. Hopefully, they will keep improving on it.