Skip to content

Queries fail to execute, localStorage key full #911

@robd003

Description

@robd003

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), <anonymous>: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.<anonymous> (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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions