Initializr: clean up generated zips to avoid IndexedDB quota exhaustion#4969
Merged
Conversation
GeneratorModel.generate() writes the project zip via openFileOutputStream, which on the JavaScript port persists to IndexedDB through LocalForage. The Blob handed to execute() retains the bytes, but the IndexedDB entry sticks around forever, so each Generate Project click accumulates a multi-MB record until the origin quota is exhausted -- after which every setItem fails, including the framework's own startup writes. Sweep stale *.zip files from getAppHomePath() before each generation, and retry once if the write hits quota, surfacing a clear "Browser storage is full" toast on persistent failure. Initializr.runApp() also kicks off the same cleanup in a background thread after the form shows, so users already stuck in the quota-full state recover on next page load without manually clearing site data. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Cloudflare Preview
|
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.
Summary
LocalForage.setItem(the JS port's backing foropenFileOutputStream) and never deletes it. After enough clicks the origin's IndexedDB quota is exhausted and every subsequentsetItem— including the framework's own startup writes (font metrics, etc.) — throwsQuotaExceededException.GeneratorModel.generate()now sweeps*.zipfiles fromgetAppHomePath()before each write, and onIOExceptioncleans up again and retries once before surfacing a "Browser storage is full" toast.Initializr.runApp()kicks off the same cleanup in a backgroundDisplay.startThreadafterform.show(), so users already stuck in the quota-full state recover on the next page load without having to clear site data by hand.A deeper structural fix (skip IndexedDB entirely — build the zip in memory and stream the bytes directly to a browser download) is left for a follow-up.
Test plan
javascriptmodule and load it in a browser with a freshly-cleared origin.🤖 Generated with Claude Code