#55745: fix: flush cookie stores to disk before quitting
Description of Change
Fixes #55395 without a Chromium patch.
Root cause. The network service batches cookie writes and commits them every 30s / 512 ops, or when each NetworkContext is torn down at shutdown. Electron relied entirely on that teardown to persist cookies set shortly before quit. On linux-x64-ubsan that teardown can hit the ~EpollEventEntry() misaligned-reference UBSan report (base/message_loop/message_pump_epoll.cc:683). Because CI builds with is_ubsan_no_recover=true, that kills the network service before the commit. The browser still exits 0, so the cookie fixture's second phase reads 0 cookies. A UBSan suppression can't help, because the _abort handlers call Die() even for suppressed reports. The ignorelist is Chromium's tools/ubsan/ignorelist.txt, so changing it would mean a patch.
Fix. Chrome starts flushing every loaded storage partition as soon as shutdown begins (browser_shutdown::OnShutdownStarting() in chrome/browser/lifetime/browser_shutdown.cc), and Electron did not. Browser::Shutdown() now does the same for every session. Before the PGO profiling wait, it sends a fire-and-forget cookie store flush and calls StoragePartition::Flush(). The commit then starts early and overlaps the rest of shutdown, instead of happening only inside ~NetworkContext. Quit doesn't wait on the flush. We rely on the existing grace period in BrowserProcessIOThread::ProcessHostCleanUp() for the network service to finish.
Also sets retry: 0 on spec/api-session.spec.ts. A scan of 159 linux-x64-ubsan test job logs from 53 recent main Build runs found the cookie restart test was the only test in this file that ever needed a retry (5 times).
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
- tests are changed or added
- relevant API documentation, tutorials, and examples are updated and follow the documentation style guide
- PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, past tense, and no longer than 80 characters.
🤖 Generated with Claude Code
Release Notes
Notes: Fixed cookies set shortly before quitting sometimes not being saved to disk.
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron