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

localStorage / IndexDB write failures are fatal #18423

Open
novocaine opened this issue Aug 6, 2021 · 10 comments
Open

localStorage / IndexDB write failures are fatal #18423

novocaine opened this issue Aug 6, 2021 · 10 comments
Labels
A-Storage Storage layer of the app, including IndexedDB, local storage, etc. O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Critical Prevents work, causes data loss and/or has no workaround T-Defect Z-TravisR

Comments

@novocaine
Copy link
Contributor

Steps to reproduce

  1. Run out of disk space or use a browser that disallows writing to localStorage, such as mobile safari in private mode
  2. Perform an operation in Element Web that requires writing to localStorage. There are many of these cases all over the app.

What happened?

A console error will usually be visible as we don't typically catch these exceptions.

The app will show undefined behaviour depending on what was prevented from happening; ranging from minor state not being preserved across sessions to irretrievable data loss of state that might only be held client side.

What did you expect?

The app should gracefully handle localStorage write failure. It should inform the user and cleanly abort the current operation.

Operating system

No response

Application version

No response

How did you install the app?

No response

@novocaine novocaine added T-Defect S-Critical Prevents work, causes data loss and/or has no workaround O-Uncommon Most users are unlikely to come across this or unexpected workflow labels Aug 6, 2021
@novocaine novocaine added A-Storage Storage layer of the app, including IndexedDB, local storage, etc. T-Task Tasks for the team like planning and removed T-Defect labels Aug 25, 2021
@novocaine novocaine changed the title Generalised handling for localStorage write failures localStorage write failures are fatal Oct 4, 2021
@novocaine novocaine added T-Defect and removed T-Task Tasks for the team like planning labels Oct 4, 2021
@germain-gg germain-gg self-assigned this Oct 19, 2021
@germain-gg germain-gg removed their assignment Oct 19, 2021
@Palid Palid self-assigned this Nov 12, 2021
Palid pushed a commit to matrix-org/matrix-js-sdk that referenced this issue Nov 12, 2021
Add a way to listen to LocalStorage error events from element-web
and matrix-react-sdk in the same manner.

Related: element-hq/element-web#18423
Palid pushed a commit that referenced this issue Nov 12, 2021
WARNING: Dirty hack to be removed later in the future, via a refactor
to a proper storage-service object instead of monkeypatching all of the
localStorage calls that may or may not throw an error.
This should be properly handled in-place whenever it can throw, but this
has to do for now.

Add a way to listen to any kinds of errors thrown by LocalStorage
methods so that we can handle them on the top level and at least show
some details to the user that the app has broken due to LocalStorage
failing hard.

Related: #18423
@daniellekirkwood daniellekirkwood added X-Needs-Design X-Needs-Product More input needed from the Product team labels Nov 12, 2021
@daniellekirkwood daniellekirkwood self-assigned this Nov 12, 2021
Palid pushed a commit to matrix-org/matrix-js-sdk that referenced this issue Nov 15, 2021
Add a way to listen to LocalStorage error events from element-web
and matrix-react-sdk in the same manner.

Related: element-hq/element-web#18423
Palid pushed a commit to matrix-org/matrix-js-sdk that referenced this issue Nov 15, 2021
Add a way to listen to LocalStorage error events from element-web
and matrix-react-sdk in the same manner.

Related: element-hq/element-web#18423
germain-gg pushed a commit to matrix-org/matrix-js-sdk that referenced this issue Nov 18, 2021
Add a way to listen to LocalStorage error events from element-web
and matrix-react-sdk in the same manner.

Related: element-hq/element-web#18423
@novocaine novocaine removed X-Needs-Design X-Needs-Product More input needed from the Product team labels Jan 20, 2022
@Yoric
Copy link
Contributor

Yoric commented Feb 7, 2022

For what it's worth, it happened to me yesterday (10 minutes before my Fosdem talk) with a disk that still had 300Gb free. I suspect that some quota was hit somewhere, either by Firefox, or AppArmor, or snap, or something: https://github.com/matrix-org/element-web-rageshakes/issues/10415

@colemickens
Copy link

I'm pretty confused. I'm hitting this right now, being told that my browser isn't supported... but I just logged in yesterday, have barely had the client open, have nothing in localStorage, it seems to be in IndexedDB. How do I even recover from this state? :/

@jukefr
Copy link

jukefr commented Feb 10, 2022

While waiting for this issue to get solved :

The localStorage allowed size per origin varies browser to browser.
It is 2.5 MB on Chrome, 5 MB on Firefox by default.
I used to face this issue every month or so (with increasing frequency), which completely prevents you from sending any messages, or reacting or anything (rendering element completely unusable).
There is no error displayed on the UI and it only becomes apparent if you know about the dev tools and look at the console.

As a temporary hack for firefox you can change the default maximum storage size allowed in the about:config page under the key dom.storage.default_quota. A similar thing is probably possible on most browsers. You would want to search for something along the lines of increase localStorage default value in [browser].
Do take note that this will apply to every single website and could lead to significant increase in storage consumption potentially.

This is only a hack, it would be preferable to fix this issue on the actual app.
This workaround is also probably out of reach of non "power-users".

edit: apparently it is only possible to increase the value on firefox and opera, not chrome.

@novocaine
Copy link
Contributor Author

novocaine commented Feb 10, 2022

@colemickens @Yoric If you are experiencing fatal issues that are not obviously linked to running out of disk space, please don't comment in this issue (which is about disk space), please file a separate issue - we need all the details in the bug template from you and ideally debug logs. There are other reasons why indexDb may spontaneously combust e.g. #18625

@Yoric
Copy link
Contributor

Yoric commented Feb 10, 2022

@novocaine Sure, I'll reopen #20931.

@novocaine novocaine changed the title localStorage write failures are fatal localStorage / IndexDB write failures are fatal Feb 18, 2022
skyka13711 pushed a commit to 42-px/matrix-js-sdk that referenced this issue Apr 14, 2022
Add a way to listen to LocalStorage error events from element-web
and matrix-react-sdk in the same manner.

Related: element-hq/element-web#18423
skyka13711 pushed a commit to 42-px/matrix-js-sdk that referenced this issue Apr 14, 2022
Add a way to listen to LocalStorage error events from element-web
and matrix-react-sdk in the same manner.

Related: element-hq/element-web#18423
@t3chguy
Copy link
Member

t3chguy commented Jul 4, 2022

Needs design for the UX of the app presenting the user with a failure when the app completely breaks and a refresh may not be enough to fix it, your browser simply said that we cannot access storage or your quote is full, this may be related to your disk getting too full for your browser to be happy

@roberth
Copy link

roberth commented Apr 8, 2023

I've encountered this problem in element-desktop.

The worst part is that I had no clue that anything was wrong for more than a day. If Element had shown an error message asking for a restart, that would have been fine, but in my case, there was no way for me to know that I was not receiving any messages, even though I got quite the deluge when I figured it out eventually. (For context, I usually only respond to matrix messages, so an error message when sending would not help me usually)


Not sure if useful, but I've found these logs when restarting element-desktop after it's been sitting idle not receiving anything, after disk had been full for a couple of hours.

Apr 08 17:11:04 hostname xsession[2488556]: [2488556:0408/171104.750105:ERROR:leveldb_factory.cc(88)] Failed to open LevelDB database from /home/user/.config/Element/IndexedDB/vector_vector_0.indexeddb.leveldb,Corruption: checksum mismatch
Apr 08 17:11:04 hostname xsession[2488556]: [2488556:0408/171104.750139:ERROR:indexed_db_factory_impl.cc(677)] Got corruption for { origin: vector://vector, top-level site: vector://vector, nonce: <null>, ancestor chain bit: Same-Site }, checksum mismatch
Apr 08 17:11:04 hostname xsession[2488556]: [2488556:0408/171104.759099:ERROR:indexed_db_factory_impl.cc(813)] IndexedDB recovering from a corrupted (and deleted) database.

I also have log lines from around the time that the disk was full, but I'm not sure whether the process was element-desktop or chromium, but I guess it could be relevant either way because it's the same tech.

:ERROR:simple_index_file.cc(322)] Failed to write the temporary index file

Versions:

Element version: 1.11.24
Olm version: 3.2.12

@MayeulC
Copy link

MayeulC commented May 3, 2023

I also encountered that error while running out of disk space (updates in the background).

I would have sent an error with logs from the client, but it returns "No connected database".

Screenshot

partial_2023-05-03-094505_grim

Restarting Element twice after this (initially to try to send the logs), it looks like I didn't actually have to logout, and I'm back in my account.

Edit: I got the message again some time later (without running out of disk space again). I'm not able to skip the message anymore.

@erebion
Copy link

erebion commented Oct 25, 2023

I just had my disk running out of space while using Element Desktop. It forced me to log out and now I cannot log in, it just keeps syncing forever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Storage Storage layer of the app, including IndexedDB, local storage, etc. O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Critical Prevents work, causes data loss and/or has no workaround T-Defect Z-TravisR
Projects
None yet
Development

No branches or pull requests