Skip to content

fix: stop clearStorageData waiting on hidden views' web processes - #30

Merged
ipfizz merged 1 commit into
mainfrom
fix/clear-storage-hidden-views
Sep 29, 2026
Merged

ipfizz merged 1 commit into
mainfrom
fix/clear-storage-hidden-views

Conversation

@ipfizz

@ipfizz ipfizz commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Fixes a macOS hang where session.clearStorageData() could stall for 15 seconds and then reject. It also fixes the flaky session.clearStorageData test that has been failing CI and local pushes intermittently.

Root cause

  • clearStorageData asked WebKit to remove every data type, including WKWebsiteDataTypeMemoryCache.
  • That one type makes WebKit wait for a reply from every open page's web content process. Everything saved to disk (cookies, storage, IndexedDB, the HTTP cache, service workers) is deleted by the network process instead, which WebKit raises to foreground priority for the job.
  • macOS runs the process of a view that has been hidden, minimized or covered for more than about a second at the lowest CPU priority. On a busy CPU that process never runs, so it never replies, and the completion handler never fires.
  • The unified log of a captured hang shows it directly: WebsiteDataStore::removeData started, then only 4 of 6 web processes replied, and finished deleting never appears. In healthy runs it appears 6-15 ms after started.
  • Real apps hit this: any app that calls clearStorageData while one of its windows is hidden (a tray app is the common case) on a loaded machine.

Fix

Remove every type except the in-process memory cache. Electron's clearStorageData doesn't clear the renderer's memory cache either. The trade-off: open pages keep their in-memory cached resources until they reload. That is now documented on the session API page.

Tests

  • A new regression test stops a live web process with SIGSTOP to simulate the starved process deterministically.
    • It fails without the fix: still pending after 5 s, checked by putting the old file back.
    • It passes with the fix.
  • In the investigation, 8 full-suite runs in a row passed with every leftover window hidden, a condition that hung 2 of 2 runs without the fix.
  • bun run validate exits 0 (1902 pass, 185 skip, 0 fail).

🤖 Generated with Claude Code

@ipfizz
ipfizz merged commit cb41502 into main Sep 29, 2026
4 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