Repository navigation
fix: reclaim service cache disk usage and prune orphan partitions - #2599
Open
rickkbarbosa wants to merge 3 commits into
Open
rickkbarbosa wants to merge 3 commits into
rickkbarbosa wants to merge 3 commits into
Conversation
added 3 commits
October 21, 2026 23:51
The service webview keeps most of its disk usage outside the HTTP cache: CacheStorage and service workers are cleared by a different API, so clear-cache only reclaimed a fraction of the space it reported. Resolve the service partition (sandbox or standalone) in the renderer, validate it in the main process, and clear the HTTP cache plus cachestorage/serviceworkers/shadercache. Cookies, localStorage and IndexedDB are kept, so clearing the cache no longer logs the user out or drops the message database.
Deleting a service that lives in a sandbox partition removed persist:service-<id>, which does not exist, and left persist:sandbox-<id> behind. A service deleted on another machine (sync) was never swept either. Resolve the partition of the deleted service, drop the sandbox partition when it was the last service in the group, and run the orphan sweep on startup once the service list is available (never against an empty list, which also happens when the API fails).
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.
Motivation
Service webviews keep most of their disk usage outside the HTTP cache. Issue #1814 reports 116 GB in
Service Worker / Cache Storageafter 2.5 months, andClear cachedid not reclaim it: the button only calledsession.clearCache(), while CacheStorage and service workers are cleared by a different API.Measured on a fresh profile with four services (WhatsApp, Telegram, Slack, Gmail):
clearCache()only (current behaviour): 23 MBclearStorageData({cachestorage,serviceworkers,shadercache})only: 26 MBIntegration run against the built handler on a service partition: 27.6 MB -> 2.4 MB (-91%), with IndexedDB and cookies preserved.
Changes
src/helpers/partition-helpers.ts(new): resolves whether a service lives in its sandbox partition or its own, validates persistent partition names received over IPC, and detects orphan partition directories. Pure functions, unit-tested.clear-cacheresolves the partition sent by the renderer, validates it in the main process, and clears the HTTP cache andcachestorage/serviceworkers/shadercache. Cookies, localStorage and IndexedDB are untouched, so clearing the cache no longer logs the user out or discards the message database.clear-storage-dataaccepts the same partition (used by service deletion).Clear all cacheuses the same orphan detection, so sandbox partitions are covered too.Verification
pnpm test: 18 suites / 161 tests (19 new)pnpm typecheck: passpnpm lint(--max-warnings 0): passRisk
Clear cache; that destructive path stays on service deletion. This is a deliberate behaviour change from fix: clear service browser storage before reload or deletion #2512 worth a second opinion: clearing IndexedDB logs users out of WhatsApp/Slack and does not reclaim meaningful space.Fixes #2569. Refs #1814.