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

Add configurable handler to onWriteFail #949

Merged
merged 2 commits into from
Dec 22, 2018
Merged

Conversation

ninjacarr
Copy link
Contributor

When the storage engine fails to persist data, the exception from setItem() is by default silently ignored. This can happen when storage is full, for example when a browser refuses to allocate enough storage due to the quota being exceeded. (In Chrome, the quota is variable based on a percentage of current free disk space.)

This PR adds an optional function to PersistConfig that will be notified when this happens, which enables the application to deal with it or notify the user.

@ninjacarr
Copy link
Contributor Author

For anyone searching error messages: this provides a way to deal with the Error storing data message seen in console.

Copy link
Collaborator

@aguynamedben aguynamedben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@schallerala
Copy link

Did you try it out by disabling the local storage in Google Chrome for example? (Going into its settings and disabling cookies (therefore local storage) for that particular site, what will throw an error when trying to access window.localStorage)
Because, when I tried using writeFailHandler, it didn't do anything.

The reason is because the getStorage returns a noopStorage when hasStorage fails. noopStorage that will never fail when used inside the Promise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants