element-hq / element-hq/hydrogen-web
Prevent concurrent session access in browsers/scenarios where no service worker is available
- Dominant language
- TypeScript
- Stars
- 714
- Forks
- 131
- PR merge metrics
- No merged PRs in 30d
Description
(At least) on IE11 or local development, we don't have a service worker. Currently, we route the request to close the session id we are about to open in other tabs through it, so this doesn't work without a service worker.
We should provide a fallback, as concurrent access will likely corrupt your database:
- use a broadcastchannel if available (we can't always use this in favor of a service worker as safari does not support broadcast channels)
- poll a sessionstorage key as last resort (at 10Hz or something?), there is also a [`storage` event](https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event) but unclear how well that is supported in IE11.
we should not expose the serviceworkerhandler to the storage factory, but rather an abstraction that can fit the above fallbacks as well.
Contributor guide
Assessment
This issue has not been assessed yet.