openexchangerates / javascript-sandbox-console

a mini interactive javascript console for library/plugin demos and homepages
http://openexchangerates.github.io/javascript-sandbox-console/
MIT License
319 stars 58 forks source link

Uncaught Error: QUOTA_EXCEEDED_ERR for localStorage #5

Open pdeschen opened 12 years ago

pdeschen commented 12 years ago

Got the following error while interacting with the sandbox. I will try to inspect the actual localStorage content and report back. According to the spec, localStorage should be 5Mb which seems plenty enough for the sandbox history!

Maybe consider compress content before adding to the storage?

backbone-localStorage.min.js:8Uncaught Error: QUOTA_EXCEEDED_ERR: DOM Exception 22
_.extend.updatebackbone-localStorage.min.js:8
Backbone.syncbackbone-localStorage.min.js:8
f.extend.savebackbone.min.js:12
Sandbox.Model.Backbone.Model.extend.addHistorysandbox-console.js:86
Sandbox.Model.Backbone.Model.extend.evaluatesandbox-console.js:146
Sandbox.View.Backbone.View.extend.keydownsandbox-console.js:307
Njquery-1.6.1.min.js:16
f.event.handlejquery-1.6.1.min.js:17
f.event.add.i.handle.kjquery-1.6.1.min.js:16
wjcrowcroft commented 12 years ago

Thanks - what browser were you in?

Any ideas what commands were run that might have had an unusually large output?

I can think of several ways to limit the history to prevent this from happening which I'll look into.

pdeschen commented 12 years ago

I'm on Chrome. I don't know if the quota is set for the whole browser or on a key basis. Hence, if that's for the whole browser, data could come from any webapp. Otherwise, I don't recall typing a 5Mb full of javascript:-)

On a side note, maybe you could use the sessionStorage instead? I understand the idea of using a persistent localStorage but the sandbox might end up adding stuff forever. Another options would be to have a rolling history buffer like in a bash or something, with a configurable size. In fact, a flag could also be set during init to either use session or local storage (i.e. {persistentHistory: false})