noam-ant

#55504: fix: keep ses.setProxy() config when the network service restarts

Merged
Created: Oct 29, 2026, 7:53:35 PM
Merged: Nov 3, 2026, 10:50:13 AM
6 comments
Target: main

Description of Change

If an app has a proxy switch on the command line (--proxy-server or one of its siblings), a proxy set with ses.setProxy() doesn't survive a network service restart.

ConfigureNetworkContextParams() ends with a call to ApplyProxyModeFromCommandLine(). It runs again for every session whose NetworkContext is rebuilt after the restart. That call writes to the same per-session pref store as Session::SetProxy(), so each restart overwrites the app's proxy with the switch.

The call used to run once. Before #17431 it sat in URLRequestContextGetter::Handle::LazyInitialize(), behind the initialized_ check. #17431 added the same call to the end of what is now ConfigureNetworkContextParams(), which has no such check.

This PR applies the switches once per session in ElectronBrowserContext::InitPrefs() and drops the later call. BrowserProcessImpl::PostEarlyInitialization() already does the same for the process-wide store.

There is one behavior change. A proxy switch appended with app.commandLine.appendSwitch() after a session exists no longer reaches that session. Before, it reached it only the next time the session's network context was rebuilt. Apps that append their switches before ready see no difference.

The new test restarts the network service and checks that one session keeps its setProxy() proxy while another keeps the switch's.

Checklist

Release Notes

Notes: Fixed proxy switches replacing ses.setProxy() after a network service restart.

Backports

44-x-y
Pending
Waiting for a manual backport
45-x-y
Pending
Waiting for a manual backport
46-x-y
In-flight
PR Number
#55575
Waiting to be merged

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