Queries fail to execute, localStorage key full
- Dominant language
- JavaScript
- Stars
- 27
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
Seeing this error in DevTools Console:
```
QuotaExceededError: Failed to execute 'setItem' on 'Storage': Setting the value of 'crate.console.query_list' exceeded the quota.
at updateRecentQueries (app.bundle.js:47517:24)
at self.execute (app.bundle.js:47629:9)
at $scope.execute (app.bundle.js:47676:14)
at fn (eval at compile (vendor.bundle.js:25096:15), :4:141)
at callback (vendor.bundle.js:37671:13)
at ChildScope.$eval (vendor.bundle.js:28071:28)
at ChildScope.$apply (vendor.bundle.js:28170:25)
at HTMLDivElement. (vendor.bundle.js:37675:19)
at defaultHandlerWrapper (vendor.bundle.js:12439:11)
at HTMLDivElement.eventHandler (vendor.bundle.js:12427:9)
```
This is on Crate 6.2.2 & 6.2.3
Maybe do something like this and start evicting the oldest records in `query_list` when localStorage gets near 5mb:
```
function getLocalStorageUsedBytes() {
return Object.entries(localStorage).reduce((total, [key, value]) => {
return total + (key.length + value.length) * 2; // UTF-16 = 2 bytes/char
}, 0);
}
```
Contributor guide
Assessment
This issue has not been assessed yet.