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

fix: dom-exception on access to localStorage #999

Merged
merged 2 commits into from
Feb 7, 2020

Conversation

nunomaduro
Copy link

fix: #997

The access to the localStorage was being performed on the constructor of the localStorage driver making the algoliasearch function throwing the following exception:

Screenshot 2020-02-07 at 11 37 50

This pull request delays the access to the localStorage to the async API provided by get, set, and clear, so the error can be catch - making the fallbackable driver proxy to the next driver in the chain.

return current.get(key, defaultValue, events).catch(() => {

@nunomaduro nunomaduro added the bug label Feb 7, 2020
@nunomaduro nunomaduro self-assigned this Feb 7, 2020
@Haroenv
Copy link
Contributor

Haroenv commented Feb 7, 2020

Could you not do typeof window.localStorage === object ? window.localStorage : {}or something like this in the constructor, that way the error will still happen in the get right?

@nunomaduro nunomaduro merged commit 4d0c5ec into master Feb 7, 2020
@nunomaduro nunomaduro deleted the fix/dom-exception-on-localstorage branch February 7, 2020 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[4.x] Access to Local Storage can be blocked in Chrome
2 participants