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
Changing Firefox settings causes uncatchable exceptions #647
Comments
While this bug makes me more likely to include an in-memory fallback, it
also seems like a browser bug we should file. I’ll check into that.
I used to worry about not erroring when we aren’t successfully storing the
data, but I guess in this case we aren’t either way. We should definitely
have prominent logging when in-memory is used, but I think this increases
usability and is a good idea.
|
It seems browser weird magic to me as well. I can confirm that I couldn't find a way to catch the error and reject properly. The error appears on FF private browsing, localforage fall backs to using localstorage and data are properly stored and retrieved. |
I could open a new PR with the memory storage driver currently available under the localforage organization.
Waiting for your feedback. |
An other statement against embedign a memorystorage driver was that: |
Checking the driver, or waiting for a promise to resolve, doesn't actually tell you if storage was really permanently saved. In Chrome Incognito mode, all IndexedDB calls will succeed, even though it's effectively using memory storage. Even in normal browsing mode, there's no guarantee the browser won't suddenly decide to do a cleanup and trim its disk space usage, and delete all your site's saved content. (Or the user could do it.) The only way to be sure that storage will persist is to call navigator.storage.persist(), which is not yet widely supported but is the only way to reliably find out the answer to the question "will my storage actually be kept?" Also given the minified + compressed size of localforage is about 8kb, I'm not sure why anybody is worried about the size of the library. You could double it and nobody would notice. The kind of architecture it uses is another matter, but I don't think that should be the sole reason for not providing memory fallback. |
Adding a |
@AshleyScirra thanks for your commitment on this so far. |
Here is a fork of the original codepen using the code from PR 648. |
Tested PR #648 in Construct 2 in Firefox stable and nightly with the "never remember history" setting. It no longer throws the uncatchable error. Looks like it's sorted. |
Great! |
In Firefox, go to Options -> Privacy -> History and set Firefox to "Never remember history".
Now all localforage calls throw uncatchable exceptions. Demo URL: https://www.scirra.com/labs/bugs/localforage-crash/
This calls
localforage.getItem()
inside a try-catch block and it still throws an unhandled exception. Presumably there's an internal callback that ends up throwing an exception.IMO this behavior of Firefox is really annoying, since it breaks pages and libraries that haven't been tested specifically with this particular Firefox setting. It also results in bug reports in our software (https://www.scirra.com/forum/localstorage-crash-with-firefox-no-history_t186255). It's not clear what we can do about this simply as a consumer of the library, because there's no way to catch the exception that is thrown. So I think libraries like localforage ought to handle this to hide these quirks from library users.
This is also precisely why I think there ought to be a memory fallback as proposed in PR #555.
The text was updated successfully, but these errors were encountered: