Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Uncaught error when localstorage not available #759

Open
pacoccino opened this issue Apr 11, 2020 · 5 comments
Open

Uncaught error when localstorage not available #759

pacoccino opened this issue Apr 11, 2020 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@pacoccino
Copy link

When trying to open a box in a browser that block localstorage, there is an uncaught error and the Box.openBox method does not throw an error.

In some browsers, localStorage is not available (such as brave browser on cross-domain embedded sites, chrome when blocking third party cookies...)

Accessing the property window.localStorage throws an error (even just checking window.localStorage !== undefined)

Error thrown:
Screenshot 2020-04-11 at 14 48 47

@oed
Copy link
Member

oed commented Apr 14, 2020

@pakokrew Currently 3Box requires localstorage and IndexedDB in order to store local state. Unfortunately there is no easy way around this.

brave browser on cross-domain embedded sites

What does this mean exactly?

@oed oed added the bug Something isn't working label Apr 14, 2020
@pacoccino
Copy link
Author

@oed I know you need localStorage.
What I meant is that in such cases, the Box.openBox() method does not throw, so it's impossible to know if there is a problem.

It would be better that you catch this Uncaught exception and throw something to us, so we can display an error message to our users.

What does this mean exactly?

Inside iframes, brave disable the use of localStorage. The result is that, instead of having window.localStorage === undefined, just accessing the .localStorage throws an error. This behaviour is not implemented in most of the storage npm packages.

You can find an example here : https://mooni-widget-example.now.sh/
Open it in brave, then check the console (this example error is not from 3Box but walletconnect, same issue).

@oed
Copy link
Member

oed commented Apr 14, 2020

Thanks @pakokrew That's a good idea to throw an error if that's the case! Will put this in our backlog.

Do you know why brave disables localstorage in iframes? Is other storage methods such as IndexedDB available?

@pacoccino
Copy link
Author

That's part of privacy protecting strategy. They consider them like cross-domain/third party cookies. I don't think other types of storage will be supported. Apple's Webkit will pose a lot of problems soon also, and chrome may follow.

If you disable shields on brave, it works.

@oed
Copy link
Member

oed commented Apr 23, 2020

Hey @pakokrew, an update: We are tracking improvements to this here #772
Until that is implemented I suggest you can manually check if localstorage is available before you call openBox.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants