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 values are limited to 10Mb #8337

Closed
nunomluz opened this issue Jan 4, 2017 · 7 comments · Fixed by #15596
Closed

localStorage values are limited to 10Mb #8337

nunomluz opened this issue Jan 4, 2017 · 7 comments · Fixed by #15596

Comments

@nunomluz
Copy link

nunomluz commented Jan 4, 2017

localStorage is still limited to 10Mb. After running a few tests, it throws a:

DOMException: Failed to execute 'setItem' on 'Storage': Setting the value of 'data' exceeded the quota.

Also reported in issue 897, which is closed.

  • Electron version: 1.4.13
  • Operating system: Windows 7

Expected behavior

No limit/quota

Actual behavior

Limited to 10Mb

How to reproduce

Run localStorage.setItem('data', (new Array(11*1024*1024)).join("x"));

@kevinsawicki
Copy link
Contributor

The total storage can be over 10MB but a single value cannot be over 10MB.

Since localStorage is synchronous, saving large values may hang the application, can you elaborate on why you are saving values that large?

@kevinsawicki kevinsawicki added blocked/need-info ❌ Cannot proceed without more information and removed bug labels Jan 4, 2017
@nunomluz
Copy link
Author

nunomluz commented Jan 4, 2017

Thanks, @kevinsawicki . I'm using the redux-localstorage enhancer, which stores part of the app state in serialized JSON as a single key-value. It's not a common case, but with the current implementation I'm working on, it can exceed 10 Mb.
The app hanging is an issue, so I'll consider another approach that doesn't rely on localStorage. However, anyone using redux-localstorage might experience this issue if the persisted slice of the app state grows over time.

@kevinsawicki kevinsawicki added bug and removed blocked/need-info ❌ Cannot proceed without more information labels Jan 30, 2017
@kevinsawicki kevinsawicki changed the title localStorage is still limited to 10Mb localStorage values are limited to 10Mb Feb 15, 2017
@zcbenz zcbenz added the blocked label Jun 1, 2017
@imolorhe
Copy link

I have the same use case as mentioned by @nunomluz. My app's state is stored in localstorage. The app state is rehydrated upon initialization based on the stored state.

@SmileOffline
Copy link

You can use this library,

I worked very well in our project.

https://github.com/electron-userland/electron-json-storage

@jacobq
Copy link
Contributor

jacobq commented Nov 2, 2018

Could anyone tell me how to start going about writing a patch for this in the upstream chromium package? It looks like it's related to these:

Update: Actually, it looks like the value might be defined here, so we ought to be able to at least increase it to a very large number, if not modify the quota enforcement logic.
How does electron go about applying patches to this (assuming v4.x)? Part of the build? Time to dig into the docs?

@jacobq
Copy link
Contributor

jacobq commented Nov 2, 2018

BTW, is the reason that localStorage.sizeTest = new Array(5*Math.pow(2,20)).fill('X').join('') fails (5Mi characters) even though the quota limit is 10MiB because each character is using 2 bytes (JS strings using UTF-16)?

@jacobq
Copy link
Contributor

jacobq commented Nov 5, 2018

Looks like this should be fixed in master (#14104), but I am still seeing it in 4.0.0-nightly.20181010 and 4.0.0-beta.7 Perhaps the dom_storage... patch either isn't working or is no longer sufficient.
https://github.com/electron/electron/pull/14104/files#diff-4169ea3b0bcb7c100cdc446c32b576b6R9

jacobq added a commit to jacobq/electron that referenced this issue Nov 5, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 5, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 5, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 6, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 6, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 6, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 6, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 6, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 6, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 6, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 6, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 6, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 7, 2018
jacobq added a commit to jacobq/electron that referenced this issue Nov 7, 2018
trop-bot pushed a commit to trop-bot/electron that referenced this issue Nov 10, 2018
trop-bot pushed a commit to trop-bot/electron that referenced this issue Nov 11, 2018
trop-bot pushed a commit to trop-bot/electron that referenced this issue Nov 11, 2018
trop-bot pushed a commit to trop-bot/electron that referenced this issue Nov 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants