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

Handle local storage quota exceeding error #572

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

microbit-grace
Copy link

The following error can occur when users import a large hex / large number of data samples, adding action / data samples, or when adding to their MakeCode project:

QuotaExceededError: Failed to execute 'setItem' on 'Storage': Setting the value of 'ml' exceeded the quota.

To mitigate the issue, I have proposed adding a dialog to handle the error.

Copy link

Preview build will be at
https://review-createai.microbit.org/storage-quota/

@microbit-grace
Copy link
Author

microbit-grace commented Dec 11, 2024

Large data samples json that can be used for testing:
too-many-samples.json

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the best way of triggering the dialog, but thought it was the easiest way to wrap all the set actions in the store. Otherwise, I could write a wrapper to wrap state changes with a try-catch statement for catching quota exceeded errors, which I think is the more straightforward approach.

@microbit-grace microbit-grace marked this pull request as ready for review December 11, 2024 16:43
@microbit-matt-hillsdon
Copy link

I'm unsure whether error handling is the right route, or at least unsure if it should be the primary way to address the issue.

Other options we can consider:

  • figure out practical limits (we know it's Edge/Chrome so likely 5MB - but check!) and impose restrictions on actions/samples that ensure we stay below
  • potentially, we could store action data in a more compact format, but still in local storage
  • if we really think folks have usecases for this then local storage is likely the wrong approach to persistence at least for the actions - IndexedDB has a higher limit I think

I'd like to understand more about what folks who hit this error are actually doing and whether it makes any sense in a tool like CreateAI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants