-
Notifications
You must be signed in to change notification settings - Fork 275
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
throws exception if localStorage access is denied #120
Comments
It could automatically do a standard require instead of throwing an exception... I'd be nice to not have to worry about having the exception thrown and rendering the page useless. |
I have personally never run into the permission denied issue with |
Some errors:
Thanks for looking into this. If you need more errors/browsers let me know and I'll take a deeper look into our Sentry logs. |
I also get an error related to this when I check the "Block any sites from setting data" option in Chrome. This prevents that any code called via basket will fail to load and thus will break the site. Adding try/catch eg. https://gist.github.com/justmarkup/c1c9da55d4c84fcca084 would solve this problem. Question is, does anything speak against using try/catch? I am happy to make a PR, but want to make sure you are fine with this change? |
My only concern with try/catch is V8 has limited ability to optimise functions using this construct. If someone wants to throw together a PR we can profile and check if this will actually be an issue. |
Hi @addyosmani I just created a new branch on my fork to compare the performance, see: justmarkup@256161a I am not adding a try/catch block inside any of the functions as I think this helps with the V8 performance issue. Test with current code: https://justmarkup.com/tests/local.html I don't really know how to profile this so would be great if you could point me in the right direction or help me out here. Thanks. |
I think this is a serious issue. Testing basketjs on my IE11 I had this error: A search on the Web drove me to this Stackoverflow answer: http://stackoverflow.com/a/20848924. This was exactly my case: after correcting the integrity level of the Now, before execute basketjs, I test localstorage[1]: function lsTest(){
var test = 'test';
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
} catch(e) {
return false;
}
}
if(lsTest() === true){
console.log('presente');
}else{
console.log('assente');
} |
There are several reads from
localStorage
that are done withouttry/catch
. I see "Permission Denied" exceptions in our logs, I'm guessing from cautious users who have theirlocalstorage
disabled.The text was updated successfully, but these errors were encountered: