NoRedInk / localstorage

Elm effect manager for local storage
Other
1 stars 1 forks source link

Windows / IE - localStorage.get can error out #1

Open jleven opened 7 years ago

jleven commented 7 years ago

We are seeing the following error in Rollbar: "Error: There is not enough space on the disk." (For NRI folks, the link is: https://rollbar.com/NoRedInk/NoRedInk/items/11892/)

This is only occurring for IE on Windows.

I tracked down the line and column number for the error, and it's happening at this line in the native implementation.

My conclusion, as odd as it sounds, is that IE on Windows can raise a "not enough space" error on an attempt to read from local storage.

eeue56 commented 7 years ago

http://diveintohtml5.info/storage.html#limitations

IMO I'd be surprised if you've filled 5MB of storage. If so, it's likely you're trying to store too much in there - in the case of Elm, this could be a naive toString of a model or JSON. It's also possible that you're not clearing out enough localstorage. Unlike cookies, localstorage lives forever. An example might be if you are storing things site-wide in localstorage on multiple instances of the same page, under a different namespace, then you'll quickly fill up.

E.g

/about/me adds something with the key about_me /about/you adds something wtih the key about_you /about/them adds something with the key about_them

The tactic to manage this is to 1) minify everything you store 2) manage all localstorage updates in a single place (e.g so that each time duplicate data doesn't get added) or 3) ignore it and treat localstorage as a cache only.

FWIW, it's possible the error you got is actually just from user extensions, but hard to say without more info.

Hope that helps!

jleven commented 7 years ago

Hey Noah! I appreciate the advice, but I think it's a little beside the point. If I'm understanding the situation correctly, the line I reference above in the native implementation needs to be in a try block. We are getting a runtime exception when we should be getting an Elm error.

eeue56 commented 7 years ago

I'm skeptical that is the line that is problematic - there doesn't seem to be anything that I can find that would suggest that would be the case. If that is the case, you should be able to reproduce the exact error by visiting this page on the version of IE you're running into the problem on, by filling up localstorage then trying to get an item (it has some tests at the bottom).

Feel free to add a try..catch, but I think it's worth confirming that's the actual problem first

jleven commented 7 years ago

I can't reproduce that error by filling local cache with the problematic browser / os combination. However, it occurs to me the error is not "quota exceeded" but "There is not enough space on the disk."

It may be that these users have full hard drives...

eeue56 commented 7 years ago

Is it happening to multiple agents, or just one or two? I would say if you can track it down to a single user, then don't worry about it (it's unlikely to be a problem here). But if it's multiple users, that's a bit concerning. Can you give me an idea of which browser/OS version it is?

The closest thing I could come across was this, which isn't the same error as what you got. However, the symptoms might be similiar - if you're loading a lot from localstorage, and somehow that manages to fill up the RAM + push more things into Window's paging, then that could give you weird errors. I'm surprised that there doesn't seem to anything on StackOverflow about this error you're getting at all

jleven commented 7 years ago

Believe it or not, it's happened to 35 different users: all IE11, and either Windows 7, 8.1, or 10

jleven commented 7 years ago

All the backtraces point to the same code: var value = localStorage.getItem(key);

eeue56 commented 7 years ago

Do you think it's possible that you're filling up localstorage with too much? I.e do you think the warning is trying to say "localstorage is full", or is it a warning on something else?

jleven commented 7 years ago

Considering that this error occurs to such a small percentage of users, I would be very surprised if we were filling up local storage so inconsistently - all we're doing is cacheing the state of the page.