redux-persist icon indicating copy to clipboard operation
redux-persist copied to clipboard

Exceeding storage quota

Open YCMitch opened this issue 7 years ago • 18 comments

Hey there,

I'm encountering the following error, after running my app for a certain amount of time: Failed to execute 'setItem' on 'Storage': Setting the value of 'persist:primary' exceeded the quota.

Has anyone seen this before? I presume the cached data is over the localStorage quota, but seeing the quota is 10mb for Chrome, I find pretty difficult to believe, unless something bizarre is going on.

Is there a means of perhaps console logging the total contents of the persisted store data?

YCMitch avatar Jul 18 '18 12:07 YCMitch

You can type localStorage and hit enter in your browser console. Alternatively you can view the Local Storage section of the "Application" tab in Chrome dev tools. Both methods will reveal the entirety of what is being held in localStorage for the current domain.

MilllerTime avatar Jul 30 '18 18:07 MilllerTime

I got this same error. screenshot 2019-03-01 at 10 02 37 am

dhwrwm avatar Mar 01 '19 04:03 dhwrwm

I am also getting same error..How to clear local storage data programatically.?

naisargparmar avatar Mar 14 '19 07:03 naisargparmar

any updates on this error?

FrenchBully avatar Jul 23 '19 21:07 FrenchBully

@FrenchBully Hi u can use localStorage.removeItem(key);

naisargparmar avatar Jul 24 '19 01:07 naisargparmar

@naisargparmar @dhwrwm @MitchEff did you get any solution for this.

prasanthyejje avatar Oct 15 '19 11:10 prasanthyejje

Kind of. The storage limit obviously can't be changed, but if you're filling up your storage limit, there may be other causes.

We've found:

  • This is often caused by issues with Redux/Normalizr accidentally causing exponential memory leaks - some of our entities would have arrays of relationships with 100,000 of the same object, cause it's pushed/mutated every render, or something like that
  • Purging the persistor after logging in stops these things getting out-of-hand - once we've got a fresh set of data from the API, the persisted data is no longer relevant. If we clear it each time (and there's no normalization issues), it doesn't creep up in size.

Hope that helps. It's not a perfect answer, but if your localStorage is full, you've most likely done something wrong.

YCMitch avatar Oct 15 '19 11:10 YCMitch

@prasanthyejje I am using localStorage.removeItem(key) to clear storage. or u can generate multiple different keys under localStorage. Also @MitchEff said Storage limit can't be changed. so try to generate different keys under localStorage or clear storage.

naisargparmar avatar Dec 13 '19 01:12 naisargparmar

try to limit the data that you are fetching, in my case I have 57 data that's why I set an offset and limit to make it 20 and then I added a load more button to load the other 20 and so on

fabellonnoe avatar Feb 08 '20 15:02 fabellonnoe

any solution for this? I tried remove item , it didnt work

PavanKumarRao avatar Feb 25 '20 11:02 PavanKumarRao

Fix for Web:

$ yarn add localforage

import localforage from 'localforage';

const persistConfig = {
    key: 'root',
    storage: localforage,
};

yarokon avatar Sep 01 '20 21:09 yarokon

@yarokon .. Thanks .. that worked for me !!

ravigandikote avatar Sep 08 '20 16:09 ravigandikote

thanks @yarokon

sidalii avatar Dec 02 '20 00:12 sidalii

Hello Everyone,

I have received same error message but only on the website console. But the website is working perfectly fine. I am using Redux and Sentry. Do you think is a BUG? Error

afleissner2019 avatar May 06 '21 12:05 afleissner2019

@yarokon thanks for fix, btw how to write migration for that?

captainkovalsky avatar Nov 22 '21 11:11 captainkovalsky

Kind of. The storage limit obviously can't be changed, but if you're filling up your storage limit, there may be other causes.

We've found:

  • This is often caused by issues with Redux/Normalizr accidentally causing exponential memory leaks - some of our entities would have arrays of relationships with 100,000 of the same object, cause it's pushed/mutated every render, or something like that
  • Purging the persistor after logging in stops these things getting out-of-hand - once we've got a fresh set of data from the API, the persisted data is no longer relevant. If we clear it each time (and there's no normalization issues), it doesn't creep up in size.

Hope that helps. It's not a perfect answer, but if your localStorage is full, you've most likely done something wrong.

How do you purge the persistor?

haveamission avatar Mar 06 '22 18:03 haveamission

@yarokon thanks localforage is working fine for me.

prasanthyejje avatar Apr 01 '22 05:04 prasanthyejje