Skip to content

Initializr: clean up generated zips to avoid IndexedDB quota exhaustion#4969

Merged
shai-almog merged 1 commit into
masterfrom
initializr-cleanup-generated-zips
May 16, 2026
Merged

Initializr: clean up generated zips to avoid IndexedDB quota exhaustion#4969
shai-almog merged 1 commit into
masterfrom
initializr-cleanup-generated-zips

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • Every Generate-Project click in the initializr writes a multi-MB zip into IndexedDB via LocalForage.setItem (the JS port's backing for openFileOutputStream) and never deletes it. After enough clicks the origin's IndexedDB quota is exhausted and every subsequent setItem — including the framework's own startup writes (font metrics, etc.) — throws QuotaExceededException.
  • GeneratorModel.generate() now sweeps *.zip files from getAppHomePath() before each write, and on IOException cleans up again and retries once before surfacing a "Browser storage is full" toast.
  • Initializr.runApp() kicks off the same cleanup in a background Display.startThread after form.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

  • Rebuild the initializr javascript module and load it in a browser with a freshly-cleared origin.
  • Click Generate Project repeatedly (10+) and confirm IndexedDB usage stays bounded (DevTools → Application → IndexedDB).
  • In a separate session, fill IndexedDB to quota using a tiny script, reload the initializr, and confirm the background cleanup frees the zips on its own.
  • Force-fail the write (e.g. wrap the JS-port quota check with a stub that always throws) and confirm the retry path + "Browser storage is full" toast.

🤖 Generated with Claude Code

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>
@github-actions
Copy link
Copy Markdown
Contributor

Cloudflare Preview

@shai-almog shai-almog merged commit 56ebe1c into master May 16, 2026
7 checks passed
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.

1 participant