Repository navigation
Reopen the projects database when the browser closes it - #1459
Merged
Merged
Conversation
The browser can close the IndexedDB connection itself, for example when the user clears site data, and every later save then failed. Reopen it, retrying over a few seconds as Chrome refuses an immediate reopen, and have saves wait for it. Once reopened, save the open project whole, as the database may have been cleared, and refresh the project list. If it cannot be reopened, the toast tells the user to download their hex and refresh. Each close is logged. Update @microbit/ui to 0.6.6 and close the storage error toast once a later save succeeds.
A save made while the database was reopening ran the existence check. If site data had been cleared it found no project, and the editor stopped saving it before the whole-project save could run. Such saves now write the project back. Other operations also wait for the reopen, rather than failing against the closed connection, and reject with DatabaseClosedError if it failed.
Database operations awaited a reopen on every call, which started their transactions a step later even when no reopen was in progress. Now they only wait while one is in progress or has failed.
A later successful save now closes the storage error toast, so tests that failed only the first write lost the toast before checking it. Fail every write instead, and test that the toast closes once writes work again.
|
Preview build will be at |
microbit-matt-hillsdon
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The browser can close the IndexedDB connection itself, for example when the user clears site data, and every later save then failed. Seen on beta in Sentry.
hex and refresh, reusing the existing content-load-error string.
Tested in Chrome by clearing site data while editing, and by simulating a storage quota in DevTools to show and then close the toast.