Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] If local storage is unavailable, provide an in-memory alternative #188

Open
csharpfritz opened this issue Aug 27, 2022 · 7 comments
Labels
Feature Request Request to add a new feature Needs: Feedback The issues needs feedback before implementing

Comments

@csharpfritz
Copy link

Is your feature request related to a problem? Please describe.
If a user has disabled cookies in their browser, all local storage access throws an error.

Describe the solution you'd like
Can we provide an alternate in-memory storage provider instead of using the browser localStorage so that code will still work, but not persist between sessions.

@csharpfritz csharpfritz added Feature Request Request to add a new feature Triage Issue needs to be triaged labels Aug 27, 2022
@chrissainty
Copy link
Member

chrissainty commented Aug 27, 2022

Hey @csharpfritz!

Thanks for raising this issue. I didn't realise local storage was disabled along with cookies--you learn something new everyday!

Yes, I think swapping to an in-memory option would be possible. It's what we do for the test extensions already.

I think this should be a setting developers turn on, rather than being a default. Some new API like, EnableInMemoryStorageFallback. We can then use the result of the navigator.cookieEnabled JavaScript API to enable the in-memory provider.

@chrissainty chrissainty added Feature New feature that will be added to the project Needs: Design The issues needs design work before implementing and removed Feature Request Request to add a new feature Triage Issue needs to be triaged labels Aug 27, 2022
@csharpfritz
Copy link
Author

csharpfritz commented Aug 27, 2022 via email

@chrissainty
Copy link
Member

chrissainty commented Aug 28, 2022

Interesting, what use would the exception have for developers? The issue will only surface when the application is running on end users devices. Throwing an exception at that point would potentially kill the application, depending on how the developer has designed their code.

Wouldn't this be a feature a developer would enable ahead of time in order to keep things running if the end user has disabled cookies?

EDIT: Just realised, do you mean throw an exception if the developer hasn't enabled the new in-memory feature? So thing don't fail silently.

@csharpfritz
Copy link
Author

I'm referring to an exception if AppSettings is inaccessible and the In-Memory fallback is not enabled.

"AppSettingsUnavailableException" or similar

@joepvtl
Copy link

joepvtl commented Sep 8, 2022

Hi,

This would be a great addition! Am I correct to assume that data in the InMemory fallback only exists untill the user reloads the app?

@csharpfritz
Copy link
Author

csharpfritz commented Sep 8, 2022 via email

@chrissainty
Copy link
Member

chrissainty commented Nov 9, 2022

Sorry this has taken so long to make any progress. I've added in a new BrowserStorageDisabledException that will through if the browsers storage is unavailable.

For now, I've decided not to implement a fall back though. This is due to the fact it will behave differently to how local storage, i.e. not persistent and I'd like to get a bit more feedback on this before I add it to the library.

The work for the exception has been separated out into #192 to keep things tidy. This issue can remain for the potential fallback option.

@chrissainty chrissainty removed the Needs: Design The issues needs design work before implementing label Nov 9, 2022
@chrissainty chrissainty changed the title Handle Disabled LocalStorage in Browser and substitute an in-memory provider If local storage is unavailable, provide an in-memory alternative Nov 9, 2022
@chrissainty chrissainty added Feature Request Request to add a new feature Needs: Feedback The issues needs feedback before implementing and removed Feature New feature that will be added to the project labels Nov 9, 2022
@chrissainty chrissainty changed the title If local storage is unavailable, provide an in-memory alternative [FEATURE REQUEST] If local storage is unavailable, provide an in-memory alternative Nov 9, 2022
@chrissainty chrissainty changed the title [FEATURE REQUEST] If local storage is unavailable, provide an in-memory alternative [Feature Request] If local storage is unavailable, provide an in-memory alternative Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Request to add a new feature Needs: Feedback The issues needs feedback before implementing
Projects
None yet
Development

No branches or pull requests

3 participants