jkleinsc

#55745: fix: flush cookie stores to disk before quitting

Merged
Created: Nov 11, 2026, 4:47:15 PM
Merged: Nov 12, 2026, 12:17:03 PM
4 comments
Target: main

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

🤖 Generated with Claude Code

Release Notes

Notes: Fixed cookies set shortly before quitting sometimes not being saved to disk.

Backports

45-x-y
Merged
PR Number
#55773
Merged At
Nov 12, 2026, 1:38:04 PM
Released In
v45.3.2
Release Date
Nov 12, 2026, 3:18:32 PM
46-x-y
Merged
PR Number
#55772
Merged At
Nov 12, 2026, 1:39:12 PM
Released In
Not yet
Release Date
Not yet

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

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